diff --git a/sdk/monitor/azure-mgmt-monitor/CHANGELOG.md b/sdk/monitor/azure-mgmt-monitor/CHANGELOG.md index 29d3bb53ac072..428f0ed19e80c 100644 --- a/sdk/monitor/azure-mgmt-monitor/CHANGELOG.md +++ b/sdk/monitor/azure-mgmt-monitor/CHANGELOG.md @@ -1,5 +1,244 @@ # Release History +## 7.0.0b1 (2025-02-07) + +### Features Added + + - Client `MonitorManagementClient` added operation group `action_groups` + - Client `MonitorManagementClient` added operation group `activity_log_alerts` + - Client `MonitorManagementClient` added operation group `activity_logs` + - Client `MonitorManagementClient` added operation group `tenant_activity_logs` + - Client `MonitorManagementClient` added operation group `alert_rule_incidents` + - Client `MonitorManagementClient` added operation group `autoscale_settings` + - Client `MonitorManagementClient` added operation group `predictive_metric` + - Client `MonitorManagementClient` added operation group `baselines` + - Client `MonitorManagementClient` added operation group `diagnostic_settings` + - Client `MonitorManagementClient` added operation group `diagnostic_settings_category` + - Client `MonitorManagementClient` added operation group `event_categories` + - Client `MonitorManagementClient` added operation group `guest_diagnostics_settings` + - Client `MonitorManagementClient` added operation group `guest_diagnostics_settings_association` + - Client `MonitorManagementClient` added operation group `log_profiles` + - Client `MonitorManagementClient` added operation group `metric_alerts` + - Client `MonitorManagementClient` added operation group `metric_alerts_status` + - Client `MonitorManagementClient` added operation group `metric_definitions` + - Client `MonitorManagementClient` added operation group `metric_namespaces` + - Client `MonitorManagementClient` added operation group `metrics` + - Client `MonitorManagementClient` added operation group `operations` + - Client `MonitorManagementClient` added operation group `scheduled_query_rules` + - Client `MonitorManagementClient` added operation group `service_diagnostic_settings` + - Client `MonitorManagementClient` added operation group `vm_insights` + - Client `MonitorManagementClient` added operation group `private_link_scopes` + - Client `MonitorManagementClient` added operation group `private_link_scope_operation_status` + - Client `MonitorManagementClient` added operation group `private_link_resources` + - Client `MonitorManagementClient` added operation group `private_endpoint_connections` + - Client `MonitorManagementClient` added operation group `private_link_scoped_resources` + - Client `MonitorManagementClient` added operation group `subscription_diagnostic_settings` + - Added model `Action` + - Added model `ActionDetail` + - Added model `ActionGroupList` + - Added model `ActionGroupResource` + - Added model `ActivityLogAlertActionGroup` + - Added model `ActivityLogAlertActionList` + - Added model `ActivityLogAlertAllOfCondition` + - Added model `ActivityLogAlertLeafCondition` + - Added model `ActivityLogAlertList` + - Added model `ActivityLogAlertPatchBody` + - Added model `ActivityLogAlertResource` + - Added enum `AggregationType` + - Added enum `AggregationTypeEnum` + - Added enum `AlertSeverity` + - Added model `AlertingAction` + - Added model `ArmRoleReceiver` + - Added model `AutomationRunbookReceiver` + - Added model `AutoscaleErrorResponse` + - Added model `AutoscaleErrorResponseError` + - Added model `AutoscaleNotification` + - Added model `AutoscaleProfile` + - Added model `AutoscaleSettingResource` + - Added model `AutoscaleSettingResourceCollection` + - Added model `AutoscaleSettingResourcePatch` + - Added model `AzNsActionGroup` + - Added model `AzureFunctionReceiver` + - Added model `AzureMonitorPrivateLinkScope` + - Added model `AzureMonitorPrivateLinkScopeListResult` + - Added model `BaselineMetadata` + - Added enum `BaselineSensitivity` + - Added enum `CategoryType` + - Added enum `ComparisonOperationType` + - Added enum `ConditionalOperator` + - Added model `Context` + - Added enum `CreatedByType` + - Added model `Criteria` + - Added enum `CriterionType` + - Added model `DataContainer` + - Added model `DataSource` + - Added model `DataSourceConfiguration` + - Added enum `DataSourceKind` + - Added enum `DataStatus` + - Added model `DiagnosticSettingsCategoryResource` + - Added model `DiagnosticSettingsCategoryResourceCollection` + - Added model `DiagnosticSettingsResource` + - Added model `DiagnosticSettingsResourceCollection` + - Added model `Dimension` + - Added model `DynamicMetricCriteria` + - Added model `DynamicThresholdFailingPeriods` + - Added enum `DynamicThresholdOperator` + - Added enum `DynamicThresholdSensitivity` + - Added model `EmailNotification` + - Added model `EnableRequest` + - Added enum `Enabled` + - Added model `Error` + - Added model `ErrorAdditionalInfo` + - Added model `ErrorContract` + - Added model `ErrorDetail` + - Added model `ErrorDetailAdditionalInfoItem` + - Added model `ErrorResponseAutoGenerated` + - Added model `ErrorResponseAutoGenerated2` + - Added model `ErrorResponseCommon` + - Added model `ErrorResponseError` + - Added model `ErrorResponseErrorAdditionalInfoItem` + - Added model `EtwEventConfiguration` + - Added model `EtwProviderConfiguration` + - Added model `EventCategoryCollection` + - Added model `EventData` + - Added model `EventDataCollection` + - Added model `EventHubReceiver` + - Added enum `EventLevel` + - Added model `EventLogConfiguration` + - Added model `GuestDiagnosticSettingsAssociationList` + - Added model `GuestDiagnosticSettingsAssociationResource` + - Added model `GuestDiagnosticSettingsAssociationResourcePatch` + - Added model `GuestDiagnosticSettingsList` + - Added enum `GuestDiagnosticSettingsOsType` + - Added model `GuestDiagnosticSettingsPatchResource` + - Added model `GuestDiagnosticSettingsResource` + - Added model `HttpRequestInfo` + - Added model `Incident` + - Added model `IncidentListResult` + - Added model `ItsmReceiver` + - Added model `LocalizableString` + - Added model `LocalizableStringAutoGenerated` + - Added model `LogMetricTrigger` + - Added model `LogProfileCollection` + - Added model `LogProfileResource` + - Added model `LogProfileResourcePatch` + - Added model `LogSearchRuleResource` + - Added model `LogSearchRuleResourceCollection` + - Added model `LogSearchRuleResourcePatch` + - Added model `LogSettings` + - Added model `LogSettingsAutoGenerated` + - Added model `LogToMetricAction` + - Added model `LogicAppReceiver` + - Added model `MetadataValue` + - Added model `Metric` + - Added model `MetricAlertAction` + - Added model `MetricAlertCriteria` + - Added model `MetricAlertMultipleResourceMultipleMetricCriteria` + - Added model `MetricAlertResource` + - Added model `MetricAlertResourceCollection` + - Added model `MetricAlertResourcePatch` + - Added model `MetricAlertSingleResourceMultipleMetricCriteria` + - Added model `MetricAlertStatus` + - Added model `MetricAlertStatusCollection` + - Added model `MetricAlertStatusProperties` + - Added model `MetricAvailability` + - Added model `MetricBaselinesResponse` + - Added enum `MetricClass` + - Added model `MetricCriteria` + - Added model `MetricDefinition` + - Added model `MetricDefinitionCollection` + - Added model `MetricDimension` + - Added model `MetricNamespace` + - Added model `MetricNamespaceCollection` + - Added model `MetricNamespaceName` + - Added model `MetricSettings` + - Added model `MetricSettingsAutoGenerated` + - Added model `MetricSingleDimension` + - Added enum `MetricStatisticType` + - Added model `MetricTrigger` + - Added enum `MetricTriggerType` + - Added enum `MetricUnit` + - Added model `MetricValue` + - Added model `MultiMetricCriteria` + - Added enum `NamespaceClassification` + - Added model `NotificationRequestBody` + - Added enum `Odatatype` + - Added enum `OnboardingStatus` + - Added model `Operation` + - Added model `OperationDisplay` + - Added model `OperationListResult` + - Added model `OperationStatus` + - Added enum `Operator` + - Added model `PerformanceCounterConfiguration` + - Added model `PredictiveAutoscalePolicy` + - Added enum `PredictiveAutoscalePolicyScaleMode` + - Added model `PredictiveResponse` + - Added model `PredictiveValue` + - Added model `PrivateEndpointConnection` + - Added model `PrivateEndpointConnectionListResult` + - Added model `PrivateEndpointProperty` + - Added model `PrivateLinkResource` + - Added model `PrivateLinkResourceListResult` + - Added model `PrivateLinkScopesResource` + - Added model `PrivateLinkServiceConnectionStateProperty` + - Added enum `ProvisioningState` + - Added model `ProxyOnlyResource` + - Added model `ProxyResource` + - Added enum `QueryType` + - Added model `Recurrence` + - Added enum `RecurrenceFrequency` + - Added model `RecurrentSchedule` + - Added model `Resource` + - Added model `ResourceAutoGenerated` + - Added model `ResourceAutoGenerated2` + - Added model `ResourceAutoGenerated3` + - Added model `Response` + - Added model `ResponseWithError` + - Added enum `ResultType` + - Added model `RetentionPolicy` + - Added model `ScaleAction` + - Added model `ScaleCapacity` + - Added enum `ScaleDirection` + - Added model `ScaleRule` + - Added model `ScaleRuleMetricDimension` + - Added enum `ScaleRuleMetricDimensionOperationType` + - Added enum `ScaleType` + - Added model `Schedule` + - Added model `ScopedResource` + - Added model `ScopedResourceListResult` + - Added model `SenderAuthorization` + - Added model `ServiceDiagnosticSettingsResource` + - Added model `ServiceDiagnosticSettingsResourcePatch` + - Added model `SingleBaseline` + - Added model `SingleMetricBaseline` + - Added model `SinkConfiguration` + - Added enum `SinkConfigurationKind` + - Added model `Source` + - Added model `SubscriptionDiagnosticSettingsResource` + - Added model `SubscriptionDiagnosticSettingsResourceCollection` + - Added model `SubscriptionLogSettings` + - Added model `SubscriptionProxyOnlyResource` + - Added model `SystemData` + - Added model `TagsResource` + - Added model `TestNotificationDetailsResponse` + - Added enum `TimeAggregationType` + - Added model `TimeSeriesBaseline` + - Added model `TimeSeriesElement` + - Added model `TimeWindow` + - Added model `TriggerCondition` + - Added model `VMInsightsOnboardingStatus` + - Added model `WebhookNotification` + - Added model `WebtestLocationAvailabilityCriteria` + - Added model `WorkspaceInfo` + +### Breaking Changes + + - Deleted or renamed client operation group `MonitorManagementClient.tenant_action_groups` + - Parameter `subscription_id` of client `MonitorManagementClient` is now required + - Deleted or renamed model `TenantActionGroupList` + - Deleted or renamed model `TenantActionGroupResource` + - Deleted or renamed model `TenantActionGroupsOperations` + ## 6.0.2 (2023-08-22) ### Bugs Fixed diff --git a/sdk/monitor/azure-mgmt-monitor/README.md b/sdk/monitor/azure-mgmt-monitor/README.md index c2acef1b1fede..1599538f3bacb 100644 --- a/sdk/monitor/azure-mgmt-monitor/README.md +++ b/sdk/monitor/azure-mgmt-monitor/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Monitor Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - - diff --git a/sdk/monitor/azure-mgmt-monitor/_meta.json b/sdk/monitor/azure-mgmt-monitor/_meta.json index bf9e7afe93835..34d587abb9bc8 100644 --- a/sdk/monitor/azure-mgmt-monitor/_meta.json +++ b/sdk/monitor/azure-mgmt-monitor/_meta.json @@ -1,11 +1,11 @@ { - "commit": "817e7cea0b7e3194868825cbef6d4e62a7895951", + "commit": "a86a97dd03e0b9e692b5583e369feec3a579ef55", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.4.8", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.27.4", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/monitor/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.8 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/monitor/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-python-sdk-for-cli-only --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/monitor/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/assets.json b/sdk/monitor/azure-mgmt-monitor/assets.json deleted file mode 100644 index 6713c8b740a80..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "python", - "TagPrefix": "python/monitor/azure-mgmt-monitor", - "Tag": "python/monitor/azure-mgmt-monitor_b03b392e23" -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/__init__.py index b685879ebd27a..42cc623017574 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/__init__.py @@ -5,16 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._monitor_management_client import MonitorManagementClient -__all__ = ['MonitorManagementClient'] +from typing import TYPE_CHECKING -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._monitor_management_client import MonitorManagementClient # type: ignore from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "MonitorManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py index 358c17303bd9c..09aa0711746e0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py @@ -1,26 +1,23 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): + +class MonitorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for MonitorManagementClient. Note that all parameters used to create this instance are saved as instance @@ -32,36 +29,30 @@ class MonitorManagementClientConfiguration(Configuration): :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ): + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ): - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py index a452e1c39107b..df9319e1ae774 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py @@ -1,922 +1,273 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from . import models as _models from ._configuration import MonitorManagementClientConfiguration from ._serialization import Deserializer, Serializer +from .operations import ( + ActionGroupsOperations, + ActivityLogAlertsOperations, + ActivityLogsOperations, + AlertRuleIncidentsOperations, + AutoscaleSettingsOperations, + BaselinesOperations, + DiagnosticSettingsCategoryOperations, + DiagnosticSettingsOperations, + EventCategoriesOperations, + GuestDiagnosticsSettingsAssociationOperations, + GuestDiagnosticsSettingsOperations, + LogProfilesOperations, + MetricAlertsOperations, + MetricAlertsStatusOperations, + MetricDefinitionsOperations, + MetricNamespacesOperations, + MetricsOperations, + Operations, + PredictiveMetricOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinkScopeOperationStatusOperations, + PrivateLinkScopedResourcesOperations, + PrivateLinkScopesOperations, + ScheduledQueryRulesOperations, + ServiceDiagnosticSettingsOperations, + SubscriptionDiagnosticSettingsOperations, + TenantActivityLogsOperations, + VMInsightsOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class MonitorManagementClient(MultiApiClientMixin, _SDKClient): +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Monitor Management Client. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar action_groups: ActionGroupsOperations operations + :vartype action_groups: azure.mgmt.monitor.operations.ActionGroupsOperations + :ivar activity_log_alerts: ActivityLogAlertsOperations operations + :vartype activity_log_alerts: azure.mgmt.monitor.operations.ActivityLogAlertsOperations + :ivar activity_logs: ActivityLogsOperations operations + :vartype activity_logs: azure.mgmt.monitor.operations.ActivityLogsOperations + :ivar tenant_activity_logs: TenantActivityLogsOperations operations + :vartype tenant_activity_logs: azure.mgmt.monitor.operations.TenantActivityLogsOperations + :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations + :vartype alert_rule_incidents: azure.mgmt.monitor.operations.AlertRuleIncidentsOperations + :ivar autoscale_settings: AutoscaleSettingsOperations operations + :vartype autoscale_settings: azure.mgmt.monitor.operations.AutoscaleSettingsOperations + :ivar predictive_metric: PredictiveMetricOperations operations + :vartype predictive_metric: azure.mgmt.monitor.operations.PredictiveMetricOperations + :ivar baselines: BaselinesOperations operations + :vartype baselines: azure.mgmt.monitor.operations.BaselinesOperations + :ivar diagnostic_settings: DiagnosticSettingsOperations operations + :vartype diagnostic_settings: azure.mgmt.monitor.operations.DiagnosticSettingsOperations + :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations + :vartype diagnostic_settings_category: + azure.mgmt.monitor.operations.DiagnosticSettingsCategoryOperations + :ivar event_categories: EventCategoriesOperations operations + :vartype event_categories: azure.mgmt.monitor.operations.EventCategoriesOperations + :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations + :vartype guest_diagnostics_settings: + azure.mgmt.monitor.operations.GuestDiagnosticsSettingsOperations + :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations + operations + :vartype guest_diagnostics_settings_association: + azure.mgmt.monitor.operations.GuestDiagnosticsSettingsAssociationOperations + :ivar log_profiles: LogProfilesOperations operations + :vartype log_profiles: azure.mgmt.monitor.operations.LogProfilesOperations + :ivar metric_alerts: MetricAlertsOperations operations + :vartype metric_alerts: azure.mgmt.monitor.operations.MetricAlertsOperations + :ivar metric_alerts_status: MetricAlertsStatusOperations operations + :vartype metric_alerts_status: azure.mgmt.monitor.operations.MetricAlertsStatusOperations + :ivar metric_definitions: MetricDefinitionsOperations operations + :vartype metric_definitions: azure.mgmt.monitor.operations.MetricDefinitionsOperations + :ivar metric_namespaces: MetricNamespacesOperations operations + :vartype metric_namespaces: azure.mgmt.monitor.operations.MetricNamespacesOperations + :ivar metrics: MetricsOperations operations + :vartype metrics: azure.mgmt.monitor.operations.MetricsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.monitor.operations.Operations + :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations + :vartype scheduled_query_rules: azure.mgmt.monitor.operations.ScheduledQueryRulesOperations + :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations + :vartype service_diagnostic_settings: + azure.mgmt.monitor.operations.ServiceDiagnosticSettingsOperations + :ivar vm_insights: VMInsightsOperations operations + :vartype vm_insights: azure.mgmt.monitor.operations.VMInsightsOperations + :ivar private_link_scopes: PrivateLinkScopesOperations operations + :vartype private_link_scopes: azure.mgmt.monitor.operations.PrivateLinkScopesOperations + :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations + :vartype private_link_scope_operation_status: + azure.mgmt.monitor.operations.PrivateLinkScopeOperationStatusOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: azure.mgmt.monitor.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.monitor.operations.PrivateEndpointConnectionsOperations + :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations + :vartype private_link_scoped_resources: + azure.mgmt.monitor.operations.PrivateLinkScopedResourcesOperations + :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations + :vartype subscription_diagnostic_settings: + azure.mgmt.monitor.operations.SubscriptionDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-01' - _PROFILE_TAG = "azure.mgmt.monitor.MonitorManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'activity_log_alerts': '2020-10-01', - 'activity_logs': '2015-04-01', - 'alert_rule_incidents': '2016-03-01', - 'alert_rules': '2016-03-01', - 'autoscale_settings': '2022-10-01', - 'azure_monitor_workspaces': '2021-06-03-preview', - 'baselines': '2019-03-01', - 'data_collection_endpoints': '2022-06-01', - 'data_collection_rule_associations': '2022-06-01', - 'data_collection_rules': '2022-06-01', - 'diagnostic_settings': '2021-05-01-preview', - 'diagnostic_settings_category': '2021-05-01-preview', - 'event_categories': '2015-04-01', - 'guest_diagnostics_settings': '2018-06-01-preview', - 'guest_diagnostics_settings_association': '2018-06-01-preview', - 'log_profiles': '2016-03-01', - 'management_group_diagnostic_settings': '2021-05-01-preview', - 'metric_alerts': '2018-03-01', - 'metric_alerts_status': '2018-03-01', - 'metric_definitions': '2021-05-01', - 'metric_namespaces': '2017-12-01-preview', - 'metrics': '2021-05-01', - 'monitor_operations': '2021-06-03-preview', - 'operations': '2021-05-01', - 'predictive_metric': '2022-10-01', - 'private_endpoint_connections': '2019-10-17-preview', - 'private_link_resources': '2019-10-17-preview', - 'private_link_scope_operation_status': '2019-10-17-preview', - 'private_link_scoped_resources': '2019-10-17-preview', - 'private_link_scopes': '2019-10-17-preview', - 'scheduled_query_rules': '2018-04-16', - 'service_diagnostic_settings': '2016-09-01', - 'subscription_diagnostic_settings': '2021-05-01-preview', - 'tenant_activity_logs': '2015-04-01', - 'vm_insights': '2018-11-27-preview', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( self, credential: "TokenCredential", subscription_id: str, - api_version: Optional[str]=None, base_url: str = "https://management.azure.com", - profile: KnownProfiles=KnownProfiles.default, **kwargs: Any - ): - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(MonitorManagementClient, self).__init__( - api_version=api_version, - profile=profile + ) -> None: + self._config = MonitorManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_activity_logs = TenantActivityLogsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rule_incidents = AlertRuleIncidentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.autoscale_settings = AutoscaleSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.predictive_metric = PredictiveMetricOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.event_categories = EventCategoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts_status = MetricAlertsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_namespaces = MetricNamespacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scopes = PrivateLinkScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2015-04-01: :mod:`v2015_04_01.models` - * 2015-07-01: :mod:`v2015_07_01.models` - * 2016-03-01: :mod:`v2016_03_01.models` - * 2016-09-01: :mod:`v2016_09_01.models` - * 2017-03-01-preview: :mod:`v2017_03_01_preview.models` - * 2017-04-01: :mod:`v2017_04_01.models` - * 2017-05-01-preview: :mod:`v2017_05_01_preview.models` - * 2017-12-01-preview: :mod:`v2017_12_01_preview.models` - * 2018-01-01: :mod:`v2018_01_01.models` - * 2018-03-01: :mod:`v2018_03_01.models` - * 2018-04-16: :mod:`v2018_04_16.models` - * 2018-06-01-preview: :mod:`v2018_06_01_preview.models` - * 2018-09-01: :mod:`v2018_09_01.models` - * 2018-11-27-preview: :mod:`v2018_11_27_preview.models` - * 2019-03-01: :mod:`v2019_03_01.models` - * 2019-06-01: :mod:`v2019_06_01.models` - * 2019-10-17-preview: :mod:`v2019_10_17.models` - * 2019-11-01-preview: :mod:`v2019_11_01_preview.models` - * 2020-01-01-preview: :mod:`v2020_01_01_preview.models` - * 2020-05-01-preview: :mod:`v2020_05_01_preview.models` - * 2020-10-01: :mod:`v2020_10_01.models` - * 2021-04-01: :mod:`v2021_04_01.models` - * 2021-05-01: :mod:`v2021_05_01.models` - * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` - * 2021-06-03-preview: :mod:`v2021_06_03_preview.models` - * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` - * 2021-09-01: :mod:`v2021_09_01.models` - * 2021-09-01-preview: :mod:`v2022_02_01_preview.models` - * 2022-04-01: :mod:`v2022_04_01.models` - * 2022-06-01: :mod:`v2022_06_01.models` - * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` - * 2022-10-01: :mod:`v2022_10_01.models` - * 2023-01-01: :mod:`v2023_01_01.models` - * 2023-03-01-preview: :mod:`v2023_03_01_preview.models` - """ - if api_version == '2015-04-01': - from .v2015_04_01 import models - return models - elif api_version == '2015-07-01': - from .v2015_07_01 import models - return models - elif api_version == '2016-03-01': - from .v2016_03_01 import models - return models - elif api_version == '2016-09-01': - from .v2016_09_01 import models - return models - elif api_version == '2017-03-01-preview': - from .v2017_03_01_preview import models - return models - elif api_version == '2017-04-01': - from .v2017_04_01 import models - return models - elif api_version == '2017-05-01-preview': - from .v2017_05_01_preview import models - return models - elif api_version == '2017-12-01-preview': - from .v2017_12_01_preview import models - return models - elif api_version == '2018-01-01': - from .v2018_01_01 import models - return models - elif api_version == '2018-03-01': - from .v2018_03_01 import models - return models - elif api_version == '2018-04-16': - from .v2018_04_16 import models - return models - elif api_version == '2018-06-01-preview': - from .v2018_06_01_preview import models - return models - elif api_version == '2018-09-01': - from .v2018_09_01 import models - return models - elif api_version == '2018-11-27-preview': - from .v2018_11_27_preview import models - return models - elif api_version == '2019-03-01': - from .v2019_03_01 import models - return models - elif api_version == '2019-06-01': - from .v2019_06_01 import models - return models - elif api_version == '2019-10-17-preview': - from .v2019_10_17 import models - return models - elif api_version == '2019-11-01-preview': - from .v2019_11_01_preview import models - return models - elif api_version == '2020-01-01-preview': - from .v2020_01_01_preview import models - return models - elif api_version == '2020-05-01-preview': - from .v2020_05_01_preview import models - return models - elif api_version == '2020-10-01': - from .v2020_10_01 import models - return models - elif api_version == '2021-04-01': - from .v2021_04_01 import models - return models - elif api_version == '2021-05-01': - from .v2021_05_01 import models - return models - elif api_version == '2021-05-01-preview': - from .v2021_05_01_preview import models - return models - elif api_version == '2021-06-03-preview': - from .v2021_06_03_preview import models - return models - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview import models - return models - elif api_version == '2021-09-01': - from .v2021_09_01 import models - return models - elif api_version == '2021-09-01-preview': - from .v2022_02_01_preview import models - return models - elif api_version == '2022-04-01': - from .v2022_04_01 import models - return models - elif api_version == '2022-06-01': - from .v2022_06_01 import models - return models - elif api_version == '2022-08-01-preview': - from .v2022_08_01_preview import models - return models - elif api_version == '2022-10-01': - from .v2022_10_01 import models - return models - elif api_version == '2023-01-01': - from .v2023_01_01 import models - return models - elif api_version == '2023-03-01-preview': - from .v2023_03_01_preview import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def action_groups(self): - """Instance depends on the API version: - - * 2017-04-01: :class:`ActionGroupsOperations` - * 2018-03-01: :class:`ActionGroupsOperations` - * 2018-09-01: :class:`ActionGroupsOperations` - * 2019-03-01: :class:`ActionGroupsOperations` - * 2019-06-01: :class:`ActionGroupsOperations` - * 2021-09-01: :class:`ActionGroupsOperations` - * 2022-04-01: :class:`ActionGroupsOperations` - * 2022-06-01: :class:`ActionGroupsOperations` - * 2023-01-01: :class:`ActionGroupsOperations` - """ - api_version = self._get_api_version('action_groups') - if api_version == '2017-04-01': - from .v2017_04_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2018-03-01': - from .v2018_03_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2018-09-01': - from .v2018_09_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2019-03-01': - from .v2019_03_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2019-06-01': - from .v2019_06_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2021-09-01': - from .v2021_09_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2022-04-01': - from .v2022_04_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2022-06-01': - from .v2022_06_01.operations import ActionGroupsOperations as OperationClass - elif api_version == '2023-01-01': - from .v2023_01_01.operations import ActionGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'action_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def activity_log_alerts(self): - """Instance depends on the API version: - - * 2017-03-01-preview: :class:`ActivityLogAlertsOperations` - * 2017-04-01: :class:`ActivityLogAlertsOperations` - * 2020-10-01: :class:`ActivityLogAlertsOperations` - """ - api_version = self._get_api_version('activity_log_alerts') - if api_version == '2017-03-01-preview': - from .v2017_03_01_preview.operations import ActivityLogAlertsOperations as OperationClass - elif api_version == '2017-04-01': - from .v2017_04_01.operations import ActivityLogAlertsOperations as OperationClass - elif api_version == '2020-10-01': - from .v2020_10_01.operations import ActivityLogAlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'activity_log_alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def activity_logs(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`ActivityLogsOperations` - """ - api_version = self._get_api_version('activity_logs') - if api_version == '2015-04-01': - from .v2015_04_01.operations import ActivityLogsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'activity_logs'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def alert_rule_incidents(self): - """Instance depends on the API version: - - * 2016-03-01: :class:`AlertRuleIncidentsOperations` - """ - api_version = self._get_api_version('alert_rule_incidents') - if api_version == '2016-03-01': - from .v2016_03_01.operations import AlertRuleIncidentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_rule_incidents'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def alert_rules(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`AlertRulesOperations` - * 2015-07-01: :class:`AlertRulesOperations` - * 2016-03-01: :class:`AlertRulesOperations` - """ - api_version = self._get_api_version('alert_rules') - if api_version == '2015-04-01': - from .v2015_04_01.operations import AlertRulesOperations as OperationClass - elif api_version == '2015-07-01': - from .v2015_07_01.operations import AlertRulesOperations as OperationClass - elif api_version == '2016-03-01': - from .v2016_03_01.operations import AlertRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def autoscale_settings(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`AutoscaleSettingsOperations` - * 2021-05-01-preview: :class:`AutoscaleSettingsOperations` - * 2022-10-01: :class:`AutoscaleSettingsOperations` - """ - api_version = self._get_api_version('autoscale_settings') - if api_version == '2015-04-01': - from .v2015_04_01.operations import AutoscaleSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from .v2021_05_01_preview.operations import AutoscaleSettingsOperations as OperationClass - elif api_version == '2022-10-01': - from .v2022_10_01.operations import AutoscaleSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'autoscale_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def azure_monitor_workspaces(self): - """Instance depends on the API version: - - * 2021-06-03-preview: :class:`AzureMonitorWorkspacesOperations` - """ - api_version = self._get_api_version('azure_monitor_workspaces') - if api_version == '2021-06-03-preview': - from .v2021_06_03_preview.operations import AzureMonitorWorkspacesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_monitor_workspaces'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def baselines(self): - """Instance depends on the API version: - - * 2018-09-01: :class:`BaselinesOperations` - * 2019-03-01: :class:`BaselinesOperations` - """ - api_version = self._get_api_version('baselines') - if api_version == '2018-09-01': - from .v2018_09_01.operations import BaselinesOperations as OperationClass - elif api_version == '2019-03-01': - from .v2019_03_01.operations import BaselinesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'baselines'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def data_collection_endpoints(self): - """Instance depends on the API version: - - * 2021-04-01: :class:`DataCollectionEndpointsOperations` - * 2021-09-01-preview: :class:`DataCollectionEndpointsOperations` - * 2022-06-01: :class:`DataCollectionEndpointsOperations` - """ - api_version = self._get_api_version('data_collection_endpoints') - if api_version == '2021-04-01': - from .v2021_04_01.operations import DataCollectionEndpointsOperations as OperationClass - elif api_version == '2021-09-01-preview': - from .v2022_02_01_preview.operations import DataCollectionEndpointsOperations as OperationClass - elif api_version == '2022-06-01': - from .v2022_06_01.operations import DataCollectionEndpointsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'data_collection_endpoints'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def data_collection_rule_associations(self): - """Instance depends on the API version: - - * 2019-11-01-preview: :class:`DataCollectionRuleAssociationsOperations` - * 2021-04-01: :class:`DataCollectionRuleAssociationsOperations` - * 2021-09-01-preview: :class:`DataCollectionRuleAssociationsOperations` - * 2022-06-01: :class:`DataCollectionRuleAssociationsOperations` - """ - api_version = self._get_api_version('data_collection_rule_associations') - if api_version == '2019-11-01-preview': - from .v2019_11_01_preview.operations import DataCollectionRuleAssociationsOperations as OperationClass - elif api_version == '2021-04-01': - from .v2021_04_01.operations import DataCollectionRuleAssociationsOperations as OperationClass - elif api_version == '2021-09-01-preview': - from .v2022_02_01_preview.operations import DataCollectionRuleAssociationsOperations as OperationClass - elif api_version == '2022-06-01': - from .v2022_06_01.operations import DataCollectionRuleAssociationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'data_collection_rule_associations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def data_collection_rules(self): - """Instance depends on the API version: - - * 2019-11-01-preview: :class:`DataCollectionRulesOperations` - * 2021-04-01: :class:`DataCollectionRulesOperations` - * 2021-09-01-preview: :class:`DataCollectionRulesOperations` - * 2022-06-01: :class:`DataCollectionRulesOperations` - """ - api_version = self._get_api_version('data_collection_rules') - if api_version == '2019-11-01-preview': - from .v2019_11_01_preview.operations import DataCollectionRulesOperations as OperationClass - elif api_version == '2021-04-01': - from .v2021_04_01.operations import DataCollectionRulesOperations as OperationClass - elif api_version == '2021-09-01-preview': - from .v2022_02_01_preview.operations import DataCollectionRulesOperations as OperationClass - elif api_version == '2022-06-01': - from .v2022_06_01.operations import DataCollectionRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'data_collection_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def diagnostic_settings(self): - """Instance depends on the API version: - - * 2017-05-01-preview: :class:`DiagnosticSettingsOperations` - * 2021-05-01-preview: :class:`DiagnosticSettingsOperations` - """ - api_version = self._get_api_version('diagnostic_settings') - if api_version == '2017-05-01-preview': - from .v2017_05_01_preview.operations import DiagnosticSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from .v2021_05_01_preview.operations import DiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def diagnostic_settings_category(self): - """Instance depends on the API version: - - * 2017-05-01-preview: :class:`DiagnosticSettingsCategoryOperations` - * 2021-05-01-preview: :class:`DiagnosticSettingsCategoryOperations` - """ - api_version = self._get_api_version('diagnostic_settings_category') - if api_version == '2017-05-01-preview': - from .v2017_05_01_preview.operations import DiagnosticSettingsCategoryOperations as OperationClass - elif api_version == '2021-05-01-preview': - from .v2021_05_01_preview.operations import DiagnosticSettingsCategoryOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'diagnostic_settings_category'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def event_categories(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`EventCategoriesOperations` - """ - api_version = self._get_api_version('event_categories') - if api_version == '2015-04-01': - from .v2015_04_01.operations import EventCategoriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'event_categories'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def guest_diagnostics_settings(self): - """Instance depends on the API version: - - * 2018-06-01-preview: :class:`GuestDiagnosticsSettingsOperations` - """ - api_version = self._get_api_version('guest_diagnostics_settings') - if api_version == '2018-06-01-preview': - from .v2018_06_01_preview.operations import GuestDiagnosticsSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'guest_diagnostics_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def guest_diagnostics_settings_association(self): - """Instance depends on the API version: - - * 2018-06-01-preview: :class:`GuestDiagnosticsSettingsAssociationOperations` - """ - api_version = self._get_api_version('guest_diagnostics_settings_association') - if api_version == '2018-06-01-preview': - from .v2018_06_01_preview.operations import GuestDiagnosticsSettingsAssociationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'guest_diagnostics_settings_association'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def log_profiles(self): - """Instance depends on the API version: - - * 2016-03-01: :class:`LogProfilesOperations` - """ - api_version = self._get_api_version('log_profiles') - if api_version == '2016-03-01': - from .v2016_03_01.operations import LogProfilesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'log_profiles'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def management_group_diagnostic_settings(self): - """Instance depends on the API version: - - * 2020-01-01-preview: :class:`ManagementGroupDiagnosticSettingsOperations` - * 2021-05-01-preview: :class:`ManagementGroupDiagnosticSettingsOperations` - """ - api_version = self._get_api_version('management_group_diagnostic_settings') - if api_version == '2020-01-01-preview': - from .v2020_01_01_preview.operations import ManagementGroupDiagnosticSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from .v2021_05_01_preview.operations import ManagementGroupDiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'management_group_diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_alerts(self): - """Instance depends on the API version: - - * 2018-03-01: :class:`MetricAlertsOperations` - """ - api_version = self._get_api_version('metric_alerts') - if api_version == '2018-03-01': - from .v2018_03_01.operations import MetricAlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_alerts_status(self): - """Instance depends on the API version: - - * 2018-03-01: :class:`MetricAlertsStatusOperations` - """ - api_version = self._get_api_version('metric_alerts_status') - if api_version == '2018-03-01': - from .v2018_03_01.operations import MetricAlertsStatusOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_alerts_status'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_definitions(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`MetricDefinitionsOperations` - * 2016-03-01: :class:`MetricDefinitionsOperations` - * 2017-05-01-preview: :class:`MetricDefinitionsOperations` - * 2018-01-01: :class:`MetricDefinitionsOperations` - * 2021-05-01: :class:`MetricDefinitionsOperations` - """ - api_version = self._get_api_version('metric_definitions') - if api_version == '2015-07-01': - from .v2015_07_01.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2016-03-01': - from .v2016_03_01.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2017-05-01-preview': - from .v2017_05_01_preview.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2018-01-01': - from .v2018_01_01.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2021-05-01': - from .v2021_05_01.operations import MetricDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_namespaces(self): - """Instance depends on the API version: - - * 2017-12-01-preview: :class:`MetricNamespacesOperations` - """ - api_version = self._get_api_version('metric_namespaces') - if api_version == '2017-12-01-preview': - from .v2017_12_01_preview.operations import MetricNamespacesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_namespaces'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metrics(self): - """Instance depends on the API version: - - * 2016-09-01: :class:`MetricsOperations` - * 2017-05-01-preview: :class:`MetricsOperations` - * 2018-01-01: :class:`MetricsOperations` - * 2021-05-01: :class:`MetricsOperations` - """ - api_version = self._get_api_version('metrics') - if api_version == '2016-09-01': - from .v2016_09_01.operations import MetricsOperations as OperationClass - elif api_version == '2017-05-01-preview': - from .v2017_05_01_preview.operations import MetricsOperations as OperationClass - elif api_version == '2018-01-01': - from .v2018_01_01.operations import MetricsOperations as OperationClass - elif api_version == '2021-05-01': - from .v2021_05_01.operations import MetricsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metrics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def monitor_operations(self): - """Instance depends on the API version: - - * 2021-06-03-preview: :class:`MonitorOperationsOperations` - """ - api_version = self._get_api_version('monitor_operations') - if api_version == '2021-06-03-preview': - from .v2021_06_03_preview.operations import MonitorOperationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'monitor_operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def operations(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`Operations` - * 2015-07-01: :class:`Operations` - * 2021-05-01: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2015-04-01': - from .v2015_04_01.operations import Operations as OperationClass - elif api_version == '2015-07-01': - from .v2015_07_01.operations import Operations as OperationClass - elif api_version == '2021-05-01': - from .v2021_05_01.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def predictive_metric(self): - """Instance depends on the API version: - - * 2021-05-01-preview: :class:`PredictiveMetricOperations` - * 2022-10-01: :class:`PredictiveMetricOperations` - """ - api_version = self._get_api_version('predictive_metric') - if api_version == '2021-05-01-preview': - from .v2021_05_01_preview.operations import PredictiveMetricOperations as OperationClass - elif api_version == '2022-10-01': - from .v2022_10_01.operations import PredictiveMetricOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'predictive_metric'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_endpoint_connections(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateEndpointConnectionsOperations` - * 2021-07-01-preview: :class:`PrivateEndpointConnectionsOperations` - """ - api_version = self._get_api_version('private_endpoint_connections') - if api_version == '2019-10-17-preview': - from .v2019_10_17.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_resources(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkResourcesOperations` - * 2021-07-01-preview: :class:`PrivateLinkResourcesOperations` - """ - api_version = self._get_api_version('private_link_resources') - if api_version == '2019-10-17-preview': - from .v2019_10_17.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import PrivateLinkResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_scope_operation_status(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkScopeOperationStatusOperations` - * 2021-07-01-preview: :class:`PrivateLinkScopeOperationStatusOperations` - """ - api_version = self._get_api_version('private_link_scope_operation_status') - if api_version == '2019-10-17-preview': - from .v2019_10_17.operations import PrivateLinkScopeOperationStatusOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import PrivateLinkScopeOperationStatusOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_scope_operation_status'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_scoped_resources(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkScopedResourcesOperations` - * 2021-07-01-preview: :class:`PrivateLinkScopedResourcesOperations` - """ - api_version = self._get_api_version('private_link_scoped_resources') - if api_version == '2019-10-17-preview': - from .v2019_10_17.operations import PrivateLinkScopedResourcesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import PrivateLinkScopedResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_scoped_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_scopes(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkScopesOperations` - * 2021-07-01-preview: :class:`PrivateLinkScopesOperations` - """ - api_version = self._get_api_version('private_link_scopes') - if api_version == '2019-10-17-preview': - from .v2019_10_17.operations import PrivateLinkScopesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import PrivateLinkScopesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_scopes'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def scheduled_query_rules(self): - """Instance depends on the API version: - - * 2018-04-16: :class:`ScheduledQueryRulesOperations` - * 2020-05-01-preview: :class:`ScheduledQueryRulesOperations` - * 2022-08-01-preview: :class:`ScheduledQueryRulesOperations` - """ - api_version = self._get_api_version('scheduled_query_rules') - if api_version == '2018-04-16': - from .v2018_04_16.operations import ScheduledQueryRulesOperations as OperationClass - elif api_version == '2020-05-01-preview': - from .v2020_05_01_preview.operations import ScheduledQueryRulesOperations as OperationClass - elif api_version == '2022-08-01-preview': - from .v2022_08_01_preview.operations import ScheduledQueryRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scheduled_query_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def service_diagnostic_settings(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`ServiceDiagnosticSettingsOperations` - * 2016-09-01: :class:`ServiceDiagnosticSettingsOperations` - """ - api_version = self._get_api_version('service_diagnostic_settings') - if api_version == '2015-07-01': - from .v2015_07_01.operations import ServiceDiagnosticSettingsOperations as OperationClass - elif api_version == '2016-09-01': - from .v2016_09_01.operations import ServiceDiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'service_diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def subscription_diagnostic_settings(self): - """Instance depends on the API version: - - * 2017-05-01-preview: :class:`SubscriptionDiagnosticSettingsOperations` - * 2021-05-01-preview: :class:`SubscriptionDiagnosticSettingsOperations` - """ - api_version = self._get_api_version('subscription_diagnostic_settings') - if api_version == '2017-05-01-preview': - from .v2017_05_01_preview.operations import SubscriptionDiagnosticSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from .v2021_05_01_preview.operations import SubscriptionDiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'subscription_diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def tenant_action_groups(self): - """Instance depends on the API version: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. - * 2023-03-01-preview: :class:`TenantActionGroupsOperations` - """ - api_version = self._get_api_version('tenant_action_groups') - if api_version == '2023-03-01-preview': - from .v2023_03_01_preview.operations import TenantActionGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tenant_action_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + - @property - def tenant_activity_logs(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2015-04-01: :class:`TenantActivityLogsOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse """ - api_version = self._get_api_version('tenant_activity_logs') - if api_version == '2015-04-01': - from .v2015_04_01.operations import TenantActivityLogsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tenant_activity_logs'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - @property - def vm_insights(self): - """Instance depends on the API version: + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - * 2018-11-27-preview: :class:`VMInsightsOperations` - """ - api_version = self._get_api_version('vm_insights') - if api_version == '2018-11-27-preview': - from .v2018_11_27_preview.operations import VMInsightsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'vm_insights'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - def close(self): + def close(self) -> None: self._client.close() - def __enter__(self): + + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details): + + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_patch.py similarity index 100% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_patch.py diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py index 6b97ccd93a79b..b24ab2885450d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -24,7 +25,6 @@ # # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -52,7 +52,6 @@ MutableMapping, Type, List, - Mapping, ) try: @@ -63,8 +62,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -91,6 +90,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +113,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -124,7 +125,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +144,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,6 +156,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -170,13 +178,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -189,15 +190,30 @@ class UTC(datetime.tzinfo): """Time Zone info for handling UTC""" def utcoffset(self, dt): - """UTF offset for UTC is 0.""" + """UTF offset for UTC is 0. + + :param datetime.datetime dt: The datetime + :returns: The offset + :rtype: datetime.timedelta + """ return datetime.timedelta(0) def tzname(self, dt): - """Timestamp representation.""" + """Timestamp representation. + + :param datetime.datetime dt: The datetime + :returns: The timestamp representation + :rtype: str + """ return "Z" def dst(self, dt): - """No daylight saving for UTC.""" + """No daylight saving for UTC. + + :param datetime.datetime dt: The datetime + :returns: The daylight saving time + :rtype: datetime.timedelta + """ return datetime.timedelta(hours=1) @@ -211,7 +227,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore :param datetime.timedelta offset: offset in timedelta format """ - def __init__(self, offset): + def __init__(self, offset) -> None: self.__offset = offset def utcoffset(self, dt): @@ -240,24 +256,26 @@ def __getinitargs__(self): _FLATTEN = re.compile(r"(? None: - self.additional_properties: Dict[str, Any] = {} - for k in kwargs: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -305,13 +330,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -331,7 +366,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -340,7 +379,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,14 +390,14 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[ - [str, Dict[str, Any], Any], Any - ] = attribute_transformer, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -387,12 +426,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -402,7 +444,7 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @@ -415,9 +457,10 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -433,9 +476,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -447,7 +492,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -455,21 +500,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -508,11 +557,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -547,7 +598,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -563,17 +614,20 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict :raises: SerializationError if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -599,12 +653,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -640,7 +696,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -651,7 +708,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -664,23 +721,24 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) - else: - return serialized + raise SerializationError(msg) from err + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict :raises: SerializationError if serialization fails. :raises: ValueError if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -709,18 +767,20 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str + :returns: The serialized URL path :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -734,28 +794,27 @@ def url(self, name, data, data_type, **kwargs): output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -765,19 +824,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -786,32 +846,31 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None :raises: AttributeError if required data is None. :raises: ValueError if data is None :raises: SerializationError if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -826,12 +885,11 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) - else: - return self._serialize(data, **kwargs) + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -847,23 +905,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -877,8 +938,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -888,13 +948,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -906,9 +966,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -944,16 +1009,17 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -968,7 +1034,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -976,6 +1042,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -986,7 +1053,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1000,7 +1067,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1031,56 +1098,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1088,11 +1160,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1102,30 +1175,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: TypeError if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1138,12 +1213,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: SerializationError if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1163,19 +1239,20 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int :raises: SerializationError if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1183,11 +1260,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1202,14 +1279,15 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1223,7 +1301,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1231,17 +1308,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1278,7 +1367,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1330,22 +1419,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1353,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1362,9 +1450,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1384,7 +1472,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1402,11 +1490,12 @@ def __call__(self, target_obj, response_data, content_type=None): :param str content_type: Swagger "produces" if available. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree @@ -1415,12 +1504,13 @@ def _deserialize(self, target_obj, data): :param object data: Object to deserialize. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1437,15 +1527,15 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1474,10 +1564,9 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1504,18 +1593,20 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1530,10 +1621,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1551,10 +1644,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1571,31 +1666,42 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1604,15 +1710,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1626,7 +1733,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1645,15 +1756,15 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) - else: - return self._deserialize(obj_type, data) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1670,6 +1781,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1680,11 +1792,12 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict :raises: TypeError if non-builtin datatype encountered. """ @@ -1693,7 +1806,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1719,11 +1832,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1731,6 +1843,7 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool :raises: TypeError if string format is not valid. """ @@ -1742,24 +1855,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1767,6 +1879,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1780,8 +1893,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1793,6 +1905,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1801,12 +1914,11 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1822,6 +1934,7 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1834,6 +1947,7 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1849,22 +1963,24 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal + :return: Deserialized decimal :raises: DeserializationError if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int :raises: ValueError if string format invalid. """ @@ -1877,6 +1993,7 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta :raises: DeserializationError if string format invalid. """ @@ -1886,15 +2003,15 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) - else: - return duration + raise DeserializationError(msg) from err + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date :raises: DeserializationError if string format invalid. """ @@ -1903,13 +2020,14 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time :raises: DeserializationError if string format invalid. """ @@ -1924,6 +2042,7 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1938,15 +2057,15 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1975,9 +2094,8 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_unix(attr): @@ -1985,15 +2103,16 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_version.py index 7f96c0e74060d..efe7276fe05f2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_version.py @@ -1,8 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. +# 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. # -------------------------------------------------------------------------- -VERSION = "6.0.2" +VERSION = "7.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/__init__.py index 96ce9b45c05b5..3df30ff421491 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/__init__.py @@ -5,6 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._monitor_management_client import MonitorManagementClient -__all__ = ['MonitorManagementClient'] +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._monitor_management_client import MonitorManagementClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "MonitorManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py index a1914da0a578a..fcb3eaa8e9f91 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py @@ -1,26 +1,23 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): + +class MonitorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for MonitorManagementClient. Note that all parameters used to create this instance are saved as instance @@ -32,36 +29,30 @@ class MonitorManagementClientConfiguration(Configuration): :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-monitor/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py index fa4aca79c769c..a03ff245f565e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py @@ -1,922 +1,276 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration +from .operations import ( + ActionGroupsOperations, + ActivityLogAlertsOperations, + ActivityLogsOperations, + AlertRuleIncidentsOperations, + AutoscaleSettingsOperations, + BaselinesOperations, + DiagnosticSettingsCategoryOperations, + DiagnosticSettingsOperations, + EventCategoriesOperations, + GuestDiagnosticsSettingsAssociationOperations, + GuestDiagnosticsSettingsOperations, + LogProfilesOperations, + MetricAlertsOperations, + MetricAlertsStatusOperations, + MetricDefinitionsOperations, + MetricNamespacesOperations, + MetricsOperations, + Operations, + PredictiveMetricOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + PrivateLinkScopeOperationStatusOperations, + PrivateLinkScopedResourcesOperations, + PrivateLinkScopesOperations, + ScheduledQueryRulesOperations, + ServiceDiagnosticSettingsOperations, + SubscriptionDiagnosticSettingsOperations, + TenantActivityLogsOperations, + VMInsightsOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class MonitorManagementClient(MultiApiClientMixin, _SDKClient): +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Monitor Management Client. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar action_groups: ActionGroupsOperations operations + :vartype action_groups: azure.mgmt.monitor.aio.operations.ActionGroupsOperations + :ivar activity_log_alerts: ActivityLogAlertsOperations operations + :vartype activity_log_alerts: azure.mgmt.monitor.aio.operations.ActivityLogAlertsOperations + :ivar activity_logs: ActivityLogsOperations operations + :vartype activity_logs: azure.mgmt.monitor.aio.operations.ActivityLogsOperations + :ivar tenant_activity_logs: TenantActivityLogsOperations operations + :vartype tenant_activity_logs: azure.mgmt.monitor.aio.operations.TenantActivityLogsOperations + :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations + :vartype alert_rule_incidents: azure.mgmt.monitor.aio.operations.AlertRuleIncidentsOperations + :ivar autoscale_settings: AutoscaleSettingsOperations operations + :vartype autoscale_settings: azure.mgmt.monitor.aio.operations.AutoscaleSettingsOperations + :ivar predictive_metric: PredictiveMetricOperations operations + :vartype predictive_metric: azure.mgmt.monitor.aio.operations.PredictiveMetricOperations + :ivar baselines: BaselinesOperations operations + :vartype baselines: azure.mgmt.monitor.aio.operations.BaselinesOperations + :ivar diagnostic_settings: DiagnosticSettingsOperations operations + :vartype diagnostic_settings: azure.mgmt.monitor.aio.operations.DiagnosticSettingsOperations + :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations + :vartype diagnostic_settings_category: + azure.mgmt.monitor.aio.operations.DiagnosticSettingsCategoryOperations + :ivar event_categories: EventCategoriesOperations operations + :vartype event_categories: azure.mgmt.monitor.aio.operations.EventCategoriesOperations + :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations + :vartype guest_diagnostics_settings: + azure.mgmt.monitor.aio.operations.GuestDiagnosticsSettingsOperations + :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations + operations + :vartype guest_diagnostics_settings_association: + azure.mgmt.monitor.aio.operations.GuestDiagnosticsSettingsAssociationOperations + :ivar log_profiles: LogProfilesOperations operations + :vartype log_profiles: azure.mgmt.monitor.aio.operations.LogProfilesOperations + :ivar metric_alerts: MetricAlertsOperations operations + :vartype metric_alerts: azure.mgmt.monitor.aio.operations.MetricAlertsOperations + :ivar metric_alerts_status: MetricAlertsStatusOperations operations + :vartype metric_alerts_status: azure.mgmt.monitor.aio.operations.MetricAlertsStatusOperations + :ivar metric_definitions: MetricDefinitionsOperations operations + :vartype metric_definitions: azure.mgmt.monitor.aio.operations.MetricDefinitionsOperations + :ivar metric_namespaces: MetricNamespacesOperations operations + :vartype metric_namespaces: azure.mgmt.monitor.aio.operations.MetricNamespacesOperations + :ivar metrics: MetricsOperations operations + :vartype metrics: azure.mgmt.monitor.aio.operations.MetricsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.monitor.aio.operations.Operations + :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations + :vartype scheduled_query_rules: azure.mgmt.monitor.aio.operations.ScheduledQueryRulesOperations + :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations + :vartype service_diagnostic_settings: + azure.mgmt.monitor.aio.operations.ServiceDiagnosticSettingsOperations + :ivar vm_insights: VMInsightsOperations operations + :vartype vm_insights: azure.mgmt.monitor.aio.operations.VMInsightsOperations + :ivar private_link_scopes: PrivateLinkScopesOperations operations + :vartype private_link_scopes: azure.mgmt.monitor.aio.operations.PrivateLinkScopesOperations + :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations + :vartype private_link_scope_operation_status: + azure.mgmt.monitor.aio.operations.PrivateLinkScopeOperationStatusOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.monitor.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.monitor.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations + :vartype private_link_scoped_resources: + azure.mgmt.monitor.aio.operations.PrivateLinkScopedResourcesOperations + :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations + :vartype subscription_diagnostic_settings: + azure.mgmt.monitor.aio.operations.SubscriptionDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-01' - _PROFILE_TAG = "azure.mgmt.monitor.MonitorManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'activity_log_alerts': '2020-10-01', - 'activity_logs': '2015-04-01', - 'alert_rule_incidents': '2016-03-01', - 'alert_rules': '2016-03-01', - 'autoscale_settings': '2022-10-01', - 'azure_monitor_workspaces': '2021-06-03-preview', - 'baselines': '2019-03-01', - 'data_collection_endpoints': '2022-06-01', - 'data_collection_rule_associations': '2022-06-01', - 'data_collection_rules': '2022-06-01', - 'diagnostic_settings': '2021-05-01-preview', - 'diagnostic_settings_category': '2021-05-01-preview', - 'event_categories': '2015-04-01', - 'guest_diagnostics_settings': '2018-06-01-preview', - 'guest_diagnostics_settings_association': '2018-06-01-preview', - 'log_profiles': '2016-03-01', - 'management_group_diagnostic_settings': '2021-05-01-preview', - 'metric_alerts': '2018-03-01', - 'metric_alerts_status': '2018-03-01', - 'metric_definitions': '2021-05-01', - 'metric_namespaces': '2017-12-01-preview', - 'metrics': '2021-05-01', - 'monitor_operations': '2021-06-03-preview', - 'operations': '2021-05-01', - 'predictive_metric': '2022-10-01', - 'private_endpoint_connections': '2019-10-17-preview', - 'private_link_resources': '2019-10-17-preview', - 'private_link_scope_operation_status': '2019-10-17-preview', - 'private_link_scoped_resources': '2019-10-17-preview', - 'private_link_scopes': '2019-10-17-preview', - 'scheduled_query_rules': '2018-04-16', - 'service_diagnostic_settings': '2016-09-01', - 'subscription_diagnostic_settings': '2021-05-01-preview', - 'tenant_activity_logs': '2015-04-01', - 'vm_insights': '2018-11-27-preview', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - api_version: Optional[str] = None, base_url: str = "https://management.azure.com", - profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(MonitorManagementClient, self).__init__( - api_version=api_version, - profile=profile + self._config = MonitorManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_activity_logs = TenantActivityLogsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rule_incidents = AlertRuleIncidentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.autoscale_settings = AutoscaleSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.predictive_metric = PredictiveMetricOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.event_categories = EventCategoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts_status = MetricAlertsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_namespaces = MetricNamespacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scopes = PrivateLinkScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2015-04-01: :mod:`v2015_04_01.models` - * 2015-07-01: :mod:`v2015_07_01.models` - * 2016-03-01: :mod:`v2016_03_01.models` - * 2016-09-01: :mod:`v2016_09_01.models` - * 2017-03-01-preview: :mod:`v2017_03_01_preview.models` - * 2017-04-01: :mod:`v2017_04_01.models` - * 2017-05-01-preview: :mod:`v2017_05_01_preview.models` - * 2017-12-01-preview: :mod:`v2017_12_01_preview.models` - * 2018-01-01: :mod:`v2018_01_01.models` - * 2018-03-01: :mod:`v2018_03_01.models` - * 2018-04-16: :mod:`v2018_04_16.models` - * 2018-06-01-preview: :mod:`v2018_06_01_preview.models` - * 2018-09-01: :mod:`v2018_09_01.models` - * 2018-11-27-preview: :mod:`v2018_11_27_preview.models` - * 2019-03-01: :mod:`v2019_03_01.models` - * 2019-06-01: :mod:`v2019_06_01.models` - * 2019-10-17-preview: :mod:`v2019_10_17.models` - * 2019-11-01-preview: :mod:`v2019_11_01_preview.models` - * 2020-01-01-preview: :mod:`v2020_01_01_preview.models` - * 2020-05-01-preview: :mod:`v2020_05_01_preview.models` - * 2020-10-01: :mod:`v2020_10_01.models` - * 2021-04-01: :mod:`v2021_04_01.models` - * 2021-05-01: :mod:`v2021_05_01.models` - * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` - * 2021-06-03-preview: :mod:`v2021_06_03_preview.models` - * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` - * 2021-09-01: :mod:`v2021_09_01.models` - * 2021-09-01-preview: :mod:`v2022_02_01_preview.models` - * 2022-04-01: :mod:`v2022_04_01.models` - * 2022-06-01: :mod:`v2022_06_01.models` - * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` - * 2022-10-01: :mod:`v2022_10_01.models` - * 2023-01-01: :mod:`v2023_01_01.models` - * 2023-03-01-preview: :mod:`v2023_03_01_preview.models` - """ - if api_version == '2015-04-01': - from ..v2015_04_01 import models - return models - elif api_version == '2015-07-01': - from ..v2015_07_01 import models - return models - elif api_version == '2016-03-01': - from ..v2016_03_01 import models - return models - elif api_version == '2016-09-01': - from ..v2016_09_01 import models - return models - elif api_version == '2017-03-01-preview': - from ..v2017_03_01_preview import models - return models - elif api_version == '2017-04-01': - from ..v2017_04_01 import models - return models - elif api_version == '2017-05-01-preview': - from ..v2017_05_01_preview import models - return models - elif api_version == '2017-12-01-preview': - from ..v2017_12_01_preview import models - return models - elif api_version == '2018-01-01': - from ..v2018_01_01 import models - return models - elif api_version == '2018-03-01': - from ..v2018_03_01 import models - return models - elif api_version == '2018-04-16': - from ..v2018_04_16 import models - return models - elif api_version == '2018-06-01-preview': - from ..v2018_06_01_preview import models - return models - elif api_version == '2018-09-01': - from ..v2018_09_01 import models - return models - elif api_version == '2018-11-27-preview': - from ..v2018_11_27_preview import models - return models - elif api_version == '2019-03-01': - from ..v2019_03_01 import models - return models - elif api_version == '2019-06-01': - from ..v2019_06_01 import models - return models - elif api_version == '2019-10-17-preview': - from ..v2019_10_17 import models - return models - elif api_version == '2019-11-01-preview': - from ..v2019_11_01_preview import models - return models - elif api_version == '2020-01-01-preview': - from ..v2020_01_01_preview import models - return models - elif api_version == '2020-05-01-preview': - from ..v2020_05_01_preview import models - return models - elif api_version == '2020-10-01': - from ..v2020_10_01 import models - return models - elif api_version == '2021-04-01': - from ..v2021_04_01 import models - return models - elif api_version == '2021-05-01': - from ..v2021_05_01 import models - return models - elif api_version == '2021-05-01-preview': - from ..v2021_05_01_preview import models - return models - elif api_version == '2021-06-03-preview': - from ..v2021_06_03_preview import models - return models - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview import models - return models - elif api_version == '2021-09-01': - from ..v2021_09_01 import models - return models - elif api_version == '2021-09-01-preview': - from ..v2022_02_01_preview import models - return models - elif api_version == '2022-04-01': - from ..v2022_04_01 import models - return models - elif api_version == '2022-06-01': - from ..v2022_06_01 import models - return models - elif api_version == '2022-08-01-preview': - from ..v2022_08_01_preview import models - return models - elif api_version == '2022-10-01': - from ..v2022_10_01 import models - return models - elif api_version == '2023-01-01': - from ..v2023_01_01 import models - return models - elif api_version == '2023-03-01-preview': - from ..v2023_03_01_preview import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def action_groups(self): - """Instance depends on the API version: - - * 2017-04-01: :class:`ActionGroupsOperations` - * 2018-03-01: :class:`ActionGroupsOperations` - * 2018-09-01: :class:`ActionGroupsOperations` - * 2019-03-01: :class:`ActionGroupsOperations` - * 2019-06-01: :class:`ActionGroupsOperations` - * 2021-09-01: :class:`ActionGroupsOperations` - * 2022-04-01: :class:`ActionGroupsOperations` - * 2022-06-01: :class:`ActionGroupsOperations` - * 2023-01-01: :class:`ActionGroupsOperations` - """ - api_version = self._get_api_version('action_groups') - if api_version == '2017-04-01': - from ..v2017_04_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2018-03-01': - from ..v2018_03_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2018-09-01': - from ..v2018_09_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2019-03-01': - from ..v2019_03_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2019-06-01': - from ..v2019_06_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2021-09-01': - from ..v2021_09_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2022-04-01': - from ..v2022_04_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2022-06-01': - from ..v2022_06_01.aio.operations import ActionGroupsOperations as OperationClass - elif api_version == '2023-01-01': - from ..v2023_01_01.aio.operations import ActionGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'action_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def activity_log_alerts(self): - """Instance depends on the API version: - - * 2017-03-01-preview: :class:`ActivityLogAlertsOperations` - * 2017-04-01: :class:`ActivityLogAlertsOperations` - * 2020-10-01: :class:`ActivityLogAlertsOperations` - """ - api_version = self._get_api_version('activity_log_alerts') - if api_version == '2017-03-01-preview': - from ..v2017_03_01_preview.aio.operations import ActivityLogAlertsOperations as OperationClass - elif api_version == '2017-04-01': - from ..v2017_04_01.aio.operations import ActivityLogAlertsOperations as OperationClass - elif api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import ActivityLogAlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'activity_log_alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def activity_logs(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`ActivityLogsOperations` - """ - api_version = self._get_api_version('activity_logs') - if api_version == '2015-04-01': - from ..v2015_04_01.aio.operations import ActivityLogsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'activity_logs'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def alert_rule_incidents(self): - """Instance depends on the API version: - - * 2016-03-01: :class:`AlertRuleIncidentsOperations` - """ - api_version = self._get_api_version('alert_rule_incidents') - if api_version == '2016-03-01': - from ..v2016_03_01.aio.operations import AlertRuleIncidentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_rule_incidents'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def alert_rules(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`AlertRulesOperations` - * 2015-07-01: :class:`AlertRulesOperations` - * 2016-03-01: :class:`AlertRulesOperations` - """ - api_version = self._get_api_version('alert_rules') - if api_version == '2015-04-01': - from ..v2015_04_01.aio.operations import AlertRulesOperations as OperationClass - elif api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import AlertRulesOperations as OperationClass - elif api_version == '2016-03-01': - from ..v2016_03_01.aio.operations import AlertRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def autoscale_settings(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`AutoscaleSettingsOperations` - * 2021-05-01-preview: :class:`AutoscaleSettingsOperations` - * 2022-10-01: :class:`AutoscaleSettingsOperations` - """ - api_version = self._get_api_version('autoscale_settings') - if api_version == '2015-04-01': - from ..v2015_04_01.aio.operations import AutoscaleSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from ..v2021_05_01_preview.aio.operations import AutoscaleSettingsOperations as OperationClass - elif api_version == '2022-10-01': - from ..v2022_10_01.aio.operations import AutoscaleSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'autoscale_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def azure_monitor_workspaces(self): - """Instance depends on the API version: - - * 2021-06-03-preview: :class:`AzureMonitorWorkspacesOperations` - """ - api_version = self._get_api_version('azure_monitor_workspaces') - if api_version == '2021-06-03-preview': - from ..v2021_06_03_preview.aio.operations import AzureMonitorWorkspacesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'azure_monitor_workspaces'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def baselines(self): - """Instance depends on the API version: - - * 2018-09-01: :class:`BaselinesOperations` - * 2019-03-01: :class:`BaselinesOperations` - """ - api_version = self._get_api_version('baselines') - if api_version == '2018-09-01': - from ..v2018_09_01.aio.operations import BaselinesOperations as OperationClass - elif api_version == '2019-03-01': - from ..v2019_03_01.aio.operations import BaselinesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'baselines'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def data_collection_endpoints(self): - """Instance depends on the API version: - - * 2021-04-01: :class:`DataCollectionEndpointsOperations` - * 2021-09-01-preview: :class:`DataCollectionEndpointsOperations` - * 2022-06-01: :class:`DataCollectionEndpointsOperations` - """ - api_version = self._get_api_version('data_collection_endpoints') - if api_version == '2021-04-01': - from ..v2021_04_01.aio.operations import DataCollectionEndpointsOperations as OperationClass - elif api_version == '2021-09-01-preview': - from ..v2022_02_01_preview.aio.operations import DataCollectionEndpointsOperations as OperationClass - elif api_version == '2022-06-01': - from ..v2022_06_01.aio.operations import DataCollectionEndpointsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'data_collection_endpoints'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def data_collection_rule_associations(self): - """Instance depends on the API version: - - * 2019-11-01-preview: :class:`DataCollectionRuleAssociationsOperations` - * 2021-04-01: :class:`DataCollectionRuleAssociationsOperations` - * 2021-09-01-preview: :class:`DataCollectionRuleAssociationsOperations` - * 2022-06-01: :class:`DataCollectionRuleAssociationsOperations` - """ - api_version = self._get_api_version('data_collection_rule_associations') - if api_version == '2019-11-01-preview': - from ..v2019_11_01_preview.aio.operations import DataCollectionRuleAssociationsOperations as OperationClass - elif api_version == '2021-04-01': - from ..v2021_04_01.aio.operations import DataCollectionRuleAssociationsOperations as OperationClass - elif api_version == '2021-09-01-preview': - from ..v2022_02_01_preview.aio.operations import DataCollectionRuleAssociationsOperations as OperationClass - elif api_version == '2022-06-01': - from ..v2022_06_01.aio.operations import DataCollectionRuleAssociationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'data_collection_rule_associations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def data_collection_rules(self): - """Instance depends on the API version: - - * 2019-11-01-preview: :class:`DataCollectionRulesOperations` - * 2021-04-01: :class:`DataCollectionRulesOperations` - * 2021-09-01-preview: :class:`DataCollectionRulesOperations` - * 2022-06-01: :class:`DataCollectionRulesOperations` - """ - api_version = self._get_api_version('data_collection_rules') - if api_version == '2019-11-01-preview': - from ..v2019_11_01_preview.aio.operations import DataCollectionRulesOperations as OperationClass - elif api_version == '2021-04-01': - from ..v2021_04_01.aio.operations import DataCollectionRulesOperations as OperationClass - elif api_version == '2021-09-01-preview': - from ..v2022_02_01_preview.aio.operations import DataCollectionRulesOperations as OperationClass - elif api_version == '2022-06-01': - from ..v2022_06_01.aio.operations import DataCollectionRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'data_collection_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def diagnostic_settings(self): - """Instance depends on the API version: - - * 2017-05-01-preview: :class:`DiagnosticSettingsOperations` - * 2021-05-01-preview: :class:`DiagnosticSettingsOperations` - """ - api_version = self._get_api_version('diagnostic_settings') - if api_version == '2017-05-01-preview': - from ..v2017_05_01_preview.aio.operations import DiagnosticSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from ..v2021_05_01_preview.aio.operations import DiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def diagnostic_settings_category(self): - """Instance depends on the API version: - - * 2017-05-01-preview: :class:`DiagnosticSettingsCategoryOperations` - * 2021-05-01-preview: :class:`DiagnosticSettingsCategoryOperations` - """ - api_version = self._get_api_version('diagnostic_settings_category') - if api_version == '2017-05-01-preview': - from ..v2017_05_01_preview.aio.operations import DiagnosticSettingsCategoryOperations as OperationClass - elif api_version == '2021-05-01-preview': - from ..v2021_05_01_preview.aio.operations import DiagnosticSettingsCategoryOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'diagnostic_settings_category'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def event_categories(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`EventCategoriesOperations` - """ - api_version = self._get_api_version('event_categories') - if api_version == '2015-04-01': - from ..v2015_04_01.aio.operations import EventCategoriesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'event_categories'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def guest_diagnostics_settings(self): - """Instance depends on the API version: - - * 2018-06-01-preview: :class:`GuestDiagnosticsSettingsOperations` - """ - api_version = self._get_api_version('guest_diagnostics_settings') - if api_version == '2018-06-01-preview': - from ..v2018_06_01_preview.aio.operations import GuestDiagnosticsSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'guest_diagnostics_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def guest_diagnostics_settings_association(self): - """Instance depends on the API version: - - * 2018-06-01-preview: :class:`GuestDiagnosticsSettingsAssociationOperations` - """ - api_version = self._get_api_version('guest_diagnostics_settings_association') - if api_version == '2018-06-01-preview': - from ..v2018_06_01_preview.aio.operations import GuestDiagnosticsSettingsAssociationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'guest_diagnostics_settings_association'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def log_profiles(self): - """Instance depends on the API version: - - * 2016-03-01: :class:`LogProfilesOperations` - """ - api_version = self._get_api_version('log_profiles') - if api_version == '2016-03-01': - from ..v2016_03_01.aio.operations import LogProfilesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'log_profiles'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def management_group_diagnostic_settings(self): - """Instance depends on the API version: - - * 2020-01-01-preview: :class:`ManagementGroupDiagnosticSettingsOperations` - * 2021-05-01-preview: :class:`ManagementGroupDiagnosticSettingsOperations` - """ - api_version = self._get_api_version('management_group_diagnostic_settings') - if api_version == '2020-01-01-preview': - from ..v2020_01_01_preview.aio.operations import ManagementGroupDiagnosticSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from ..v2021_05_01_preview.aio.operations import ManagementGroupDiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'management_group_diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_alerts(self): - """Instance depends on the API version: - - * 2018-03-01: :class:`MetricAlertsOperations` - """ - api_version = self._get_api_version('metric_alerts') - if api_version == '2018-03-01': - from ..v2018_03_01.aio.operations import MetricAlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_alerts_status(self): - """Instance depends on the API version: - - * 2018-03-01: :class:`MetricAlertsStatusOperations` - """ - api_version = self._get_api_version('metric_alerts_status') - if api_version == '2018-03-01': - from ..v2018_03_01.aio.operations import MetricAlertsStatusOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_alerts_status'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_definitions(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`MetricDefinitionsOperations` - * 2016-03-01: :class:`MetricDefinitionsOperations` - * 2017-05-01-preview: :class:`MetricDefinitionsOperations` - * 2018-01-01: :class:`MetricDefinitionsOperations` - * 2021-05-01: :class:`MetricDefinitionsOperations` - """ - api_version = self._get_api_version('metric_definitions') - if api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2016-03-01': - from ..v2016_03_01.aio.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2017-05-01-preview': - from ..v2017_05_01_preview.aio.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2018-01-01': - from ..v2018_01_01.aio.operations import MetricDefinitionsOperations as OperationClass - elif api_version == '2021-05-01': - from ..v2021_05_01.aio.operations import MetricDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metric_namespaces(self): - """Instance depends on the API version: - - * 2017-12-01-preview: :class:`MetricNamespacesOperations` - """ - api_version = self._get_api_version('metric_namespaces') - if api_version == '2017-12-01-preview': - from ..v2017_12_01_preview.aio.operations import MetricNamespacesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metric_namespaces'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def metrics(self): - """Instance depends on the API version: - - * 2016-09-01: :class:`MetricsOperations` - * 2017-05-01-preview: :class:`MetricsOperations` - * 2018-01-01: :class:`MetricsOperations` - * 2021-05-01: :class:`MetricsOperations` - """ - api_version = self._get_api_version('metrics') - if api_version == '2016-09-01': - from ..v2016_09_01.aio.operations import MetricsOperations as OperationClass - elif api_version == '2017-05-01-preview': - from ..v2017_05_01_preview.aio.operations import MetricsOperations as OperationClass - elif api_version == '2018-01-01': - from ..v2018_01_01.aio.operations import MetricsOperations as OperationClass - elif api_version == '2021-05-01': - from ..v2021_05_01.aio.operations import MetricsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'metrics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def monitor_operations(self): - """Instance depends on the API version: - - * 2021-06-03-preview: :class:`MonitorOperationsOperations` - """ - api_version = self._get_api_version('monitor_operations') - if api_version == '2021-06-03-preview': - from ..v2021_06_03_preview.aio.operations import MonitorOperationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'monitor_operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def operations(self): - """Instance depends on the API version: - - * 2015-04-01: :class:`Operations` - * 2015-07-01: :class:`Operations` - * 2021-05-01: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2015-04-01': - from ..v2015_04_01.aio.operations import Operations as OperationClass - elif api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import Operations as OperationClass - elif api_version == '2021-05-01': - from ..v2021_05_01.aio.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def predictive_metric(self): - """Instance depends on the API version: - - * 2021-05-01-preview: :class:`PredictiveMetricOperations` - * 2022-10-01: :class:`PredictiveMetricOperations` - """ - api_version = self._get_api_version('predictive_metric') - if api_version == '2021-05-01-preview': - from ..v2021_05_01_preview.aio.operations import PredictiveMetricOperations as OperationClass - elif api_version == '2022-10-01': - from ..v2022_10_01.aio.operations import PredictiveMetricOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'predictive_metric'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_endpoint_connections(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateEndpointConnectionsOperations` - * 2021-07-01-preview: :class:`PrivateEndpointConnectionsOperations` - """ - api_version = self._get_api_version('private_endpoint_connections') - if api_version == '2019-10-17-preview': - from ..v2019_10_17.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_resources(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkResourcesOperations` - * 2021-07-01-preview: :class:`PrivateLinkResourcesOperations` - """ - api_version = self._get_api_version('private_link_resources') - if api_version == '2019-10-17-preview': - from ..v2019_10_17.aio.operations import PrivateLinkResourcesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_scope_operation_status(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkScopeOperationStatusOperations` - * 2021-07-01-preview: :class:`PrivateLinkScopeOperationStatusOperations` - """ - api_version = self._get_api_version('private_link_scope_operation_status') - if api_version == '2019-10-17-preview': - from ..v2019_10_17.aio.operations import PrivateLinkScopeOperationStatusOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import PrivateLinkScopeOperationStatusOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_scope_operation_status'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_scoped_resources(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkScopedResourcesOperations` - * 2021-07-01-preview: :class:`PrivateLinkScopedResourcesOperations` - """ - api_version = self._get_api_version('private_link_scoped_resources') - if api_version == '2019-10-17-preview': - from ..v2019_10_17.aio.operations import PrivateLinkScopedResourcesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import PrivateLinkScopedResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_scoped_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def private_link_scopes(self): - """Instance depends on the API version: - - * 2019-10-17-preview: :class:`PrivateLinkScopesOperations` - * 2021-07-01-preview: :class:`PrivateLinkScopesOperations` - """ - api_version = self._get_api_version('private_link_scopes') - if api_version == '2019-10-17-preview': - from ..v2019_10_17.aio.operations import PrivateLinkScopesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import PrivateLinkScopesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'private_link_scopes'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def scheduled_query_rules(self): - """Instance depends on the API version: - - * 2018-04-16: :class:`ScheduledQueryRulesOperations` - * 2020-05-01-preview: :class:`ScheduledQueryRulesOperations` - * 2022-08-01-preview: :class:`ScheduledQueryRulesOperations` - """ - api_version = self._get_api_version('scheduled_query_rules') - if api_version == '2018-04-16': - from ..v2018_04_16.aio.operations import ScheduledQueryRulesOperations as OperationClass - elif api_version == '2020-05-01-preview': - from ..v2020_05_01_preview.aio.operations import ScheduledQueryRulesOperations as OperationClass - elif api_version == '2022-08-01-preview': - from ..v2022_08_01_preview.aio.operations import ScheduledQueryRulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scheduled_query_rules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def service_diagnostic_settings(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`ServiceDiagnosticSettingsOperations` - * 2016-09-01: :class:`ServiceDiagnosticSettingsOperations` - """ - api_version = self._get_api_version('service_diagnostic_settings') - if api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import ServiceDiagnosticSettingsOperations as OperationClass - elif api_version == '2016-09-01': - from ..v2016_09_01.aio.operations import ServiceDiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'service_diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def subscription_diagnostic_settings(self): - """Instance depends on the API version: - - * 2017-05-01-preview: :class:`SubscriptionDiagnosticSettingsOperations` - * 2021-05-01-preview: :class:`SubscriptionDiagnosticSettingsOperations` - """ - api_version = self._get_api_version('subscription_diagnostic_settings') - if api_version == '2017-05-01-preview': - from ..v2017_05_01_preview.aio.operations import SubscriptionDiagnosticSettingsOperations as OperationClass - elif api_version == '2021-05-01-preview': - from ..v2021_05_01_preview.aio.operations import SubscriptionDiagnosticSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'subscription_diagnostic_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - @property - def tenant_action_groups(self): - """Instance depends on the API version: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. - * 2023-03-01-preview: :class:`TenantActionGroupsOperations` - """ - api_version = self._get_api_version('tenant_action_groups') - if api_version == '2023-03-01-preview': - from ..v2023_03_01_preview.aio.operations import TenantActionGroupsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tenant_action_groups'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + - @property - def tenant_activity_logs(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2015-04-01: :class:`TenantActivityLogsOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse """ - api_version = self._get_api_version('tenant_activity_logs') - if api_version == '2015-04-01': - from ..v2015_04_01.aio.operations import TenantActivityLogsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tenant_activity_logs'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - @property - def vm_insights(self): - """Instance depends on the API version: + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - * 2018-11-27-preview: :class:`VMInsightsOperations` - """ - api_version = self._get_api_version('vm_insights') - if api_version == '2018-11-27-preview': - from ..v2018_11_27_preview.aio.operations import VMInsightsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'vm_insights'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - - async def close(self): + async def close(self) -> None: await self._client.close() - async def __aenter__(self): + + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): + + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_patch.py similarity index 100% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_patch.py diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/__init__.py new file mode 100644 index 0000000000000..11574f0dde871 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/__init__.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._action_groups_operations import ActionGroupsOperations # type: ignore +from ._activity_log_alerts_operations import ActivityLogAlertsOperations # type: ignore +from ._activity_logs_operations import ActivityLogsOperations # type: ignore +from ._tenant_activity_logs_operations import TenantActivityLogsOperations # type: ignore +from ._alert_rule_incidents_operations import AlertRuleIncidentsOperations # type: ignore +from ._autoscale_settings_operations import AutoscaleSettingsOperations # type: ignore +from ._predictive_metric_operations import PredictiveMetricOperations # type: ignore +from ._baselines_operations import BaselinesOperations # type: ignore +from ._diagnostic_settings_operations import DiagnosticSettingsOperations # type: ignore +from ._diagnostic_settings_category_operations import DiagnosticSettingsCategoryOperations # type: ignore +from ._event_categories_operations import EventCategoriesOperations # type: ignore +from ._guest_diagnostics_settings_operations import GuestDiagnosticsSettingsOperations # type: ignore +from ._guest_diagnostics_settings_association_operations import GuestDiagnosticsSettingsAssociationOperations # type: ignore +from ._log_profiles_operations import LogProfilesOperations # type: ignore +from ._metric_alerts_operations import MetricAlertsOperations # type: ignore +from ._metric_alerts_status_operations import MetricAlertsStatusOperations # type: ignore +from ._metric_definitions_operations import MetricDefinitionsOperations # type: ignore +from ._metric_namespaces_operations import MetricNamespacesOperations # type: ignore +from ._metrics_operations import MetricsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations # type: ignore +from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations # type: ignore +from ._vm_insights_operations import VMInsightsOperations # type: ignore +from ._private_link_scopes_operations import PrivateLinkScopesOperations # type: ignore +from ._private_link_scope_operation_status_operations import PrivateLinkScopeOperationStatusOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations # type: ignore +from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ActionGroupsOperations", + "ActivityLogAlertsOperations", + "ActivityLogsOperations", + "TenantActivityLogsOperations", + "AlertRuleIncidentsOperations", + "AutoscaleSettingsOperations", + "PredictiveMetricOperations", + "BaselinesOperations", + "DiagnosticSettingsOperations", + "DiagnosticSettingsCategoryOperations", + "EventCategoriesOperations", + "GuestDiagnosticsSettingsOperations", + "GuestDiagnosticsSettingsAssociationOperations", + "LogProfilesOperations", + "MetricAlertsOperations", + "MetricAlertsStatusOperations", + "MetricDefinitionsOperations", + "MetricNamespacesOperations", + "MetricsOperations", + "Operations", + "ScheduledQueryRulesOperations", + "ServiceDiagnosticSettingsOperations", + "VMInsightsOperations", + "PrivateLinkScopesOperations", + "PrivateLinkScopeOperationStatusOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkScopedResourcesOperations", + "SubscriptionDiagnosticSettingsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_action_groups_operations.py new file mode 100644 index 0000000000000..060906ae0798a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_action_groups_operations.py @@ -0,0 +1,1447 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._action_groups_operations import ( + build_create_notifications_at_action_group_resource_level_request, + build_create_notifications_at_resource_group_level_request, + build_create_or_update_request, + build_delete_request, + build_enable_receiver_request, + build_get_request, + build_get_test_notifications_at_action_group_resource_level_request, + build_get_test_notifications_at_resource_group_level_request, + build_get_test_notifications_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_post_test_notifications_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: ~azure.mgmt.monitor.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO[bytes]], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO[bytes] type. Required. + :type action_group: ~azure.mgmt.monitor.models.ActionGroupResource or IO[bytes] + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IOBase, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActionGroupResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: + """Get an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActionGroupResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> None: + """Delete an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: ~azure.mgmt.monitor.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO[bytes]], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO[bytes] type. Required. + :type action_group_patch: ~azure.mgmt.monitor.models.ActionGroupPatchBody or IO[bytes] + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IOBase, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") + + _request = build_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActionGroupResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _post_test_notifications_initial( + self, notification_request: Union[_models.NotificationRequestBody, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IOBase, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") + + _request = build_post_test_notifications_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_post_test_notifications( + self, + notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_post_test_notifications( + self, notification_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a NotificationRequestBody type or a IO[bytes] type. Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody or IO[bytes] + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._post_test_notifications_initial( + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.TestNotificationDetailsResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.TestNotificationDetailsResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IOBase, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") + + _request = build_create_notifications_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a NotificationRequestBody type or a IO[bytes] type. Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody or IO[bytes] + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_notifications_at_resource_group_level_initial( + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.TestNotificationDetailsResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.TestNotificationDetailsResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IOBase, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") + + _request = build_create_notifications_at_action_group_resource_level_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a NotificationRequestBody type or a IO[bytes] type. Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody or IO[bytes] + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_notifications_at_action_group_resource_level_initial( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.TestNotificationDetailsResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.TestNotificationDetailsResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get_test_notifications( + self, notification_id: str, **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param notification_id: The notification id. Required. + :type notification_id: str + :return: TestNotificationDetailsResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.TestNotificationDetailsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + + _request = build_get_test_notifications_request( + notification_id=notification_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, resource_group_name: str, notification_id: str, **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_id: The notification id. Required. + :type notification_id: str + :return: TestNotificationDetailsResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.TestNotificationDetailsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + + _request = build_get_test_notifications_at_resource_group_level_request( + resource_group_name=resource_group_name, + notification_id=notification_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_id: The notification id. Required. + :type notification_id: str + :return: TestNotificationDetailsResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.TestNotificationDetailsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + + _request = build_get_test_notifications_at_action_group_resource_level_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_id=notification_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: + """Get a list of all action groups in a subscription. + + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActionGroupResource"]: + """Get a list of all action groups in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def enable_receiver( + self, + resource_group_name: str, + action_group_name: str, + enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_request: ~azure.mgmt.monitor.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def enable_receiver( + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def enable_receiver( + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO[bytes]], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO[bytes] + type. Required. + :type enable_request: ~azure.mgmt.monitor.models.EnableRequest or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IOBase, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") + + _request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_activity_log_alerts_operations.py new file mode 100644 index 0000000000000..d989a4ec66368 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_activity_log_alerts_operations.py @@ -0,0 +1,577 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._activity_log_alerts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_id_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ActivityLogAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: Union[_models.ActivityLogAlertResource, IO[bytes]], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Is either a + ActivityLogAlertResource type or a IO[bytes] type. Required. + :type activity_log_alert: ~azure.mgmt.monitor.models.ActivityLogAlertResource or IO[bytes] + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert, (IOBase, bytes)): + _content = activity_log_alert + else: + _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Get an activity log alert. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any) -> None: + """Delete an activity log alert. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: _models.ActivityLogAlertPatchBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: ~azure.mgmt.monitor.models.ActivityLogAlertPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: Union[_models.ActivityLogAlertPatchBody, IO[bytes]], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a + ActivityLogAlertPatchBody type or a IO[bytes] type. Required. + :type activity_log_alert_patch: ~azure.mgmt.monitor.models.ActivityLogAlertPatchBody or + IO[bytes] + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_patch, (IOBase, bytes)): + _content = activity_log_alert_patch + else: + _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertPatchBody") + + _request = build_update_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: + """Get a list of all activity log alerts in a subscription. + + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ActivityLogAlertResource"]: + """Get a list of all activity log alerts in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_activity_logs_operations.py new file mode 100644 index 0000000000000..5ab66b9092339 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_activity_logs_operations.py @@ -0,0 +1,144 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._activity_logs_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ActivityLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`activity_logs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.EventData"]: + """Provides the list of records from the activity logs. + + :param filter: Reduces the set of data collected.\\ :code:`
`This argument is required and + it also requires at least the start date/time.\\ :code:`
`The **$filter** argument is very + restricted and allows only the following patterns.\\ :code:`
`- *List events for a resource + group*\\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.\\ :code:`
`- + *List events for resource*\\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and + eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.\\ + :code:`
`- *List events for a subscription in a time range*\\ : $filter=eventTimestamp ge + '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.\\ + :code:`
`- *List events for a resource provider*\\ : $filter=eventTimestamp ge + '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and + resourceProvider eq 'resourceProviderName'.\\ :code:`
`- *List events for a correlation + Id*\\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.\\ :code:`
`\\ + :code:`
`\\ **NOTE**\\ : No other syntax is allowed. Required. + :type filter: str + :param select: Used to fetch events with only the given properties.\\ :code:`
`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*. Default value is None. + :type select: str + :return: An iterator like instance of either EventData or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + select=select, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventDataCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_alert_rule_incidents_operations.py new file mode 100644 index 0000000000000..265a8c1c9538f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_alert_rule_incidents_operations.py @@ -0,0 +1,188 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._alert_rule_incidents_operations import build_get_request, build_list_by_alert_rule_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AlertRuleIncidentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`alert_rule_incidents` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, rule_name: str, incident_name: str, **kwargs: Any + ) -> _models.Incident: + """Gets an incident associated to an alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param incident_name: The name of the incident to retrieve. Required. + :type incident_name: str + :return: Incident or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.Incident + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.Incident] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + incident_name=incident_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Incident", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_alert_rule( + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Incident"]: + """Gets a list of incidents associated to an alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: An iterator like instance of either Incident or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.Incident] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.IncidentListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_alert_rule_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IncidentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_autoscale_settings_operations.py new file mode 100644 index 0000000000000..65f9048e2d48c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_autoscale_settings_operations.py @@ -0,0 +1,577 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._autoscale_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AutoscaleSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`autoscale_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AutoscaleSettingResource"]: + """Lists the autoscale settings for a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: _models.AutoscaleSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: Union[_models.AutoscaleSettingResource, IO[bytes]], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.AutoscaleSettingResource or IO[bytes] + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleSettingResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any) -> None: + """Deletes and autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Gets an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: ~azure.mgmt.monitor.models.AutoscaleSettingResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO[bytes] type. Required. + :type autoscale_setting_resource: ~azure.mgmt.monitor.models.AutoscaleSettingResourcePatch or + IO[bytes] + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(autoscale_setting_resource, (IOBase, bytes)): + _content = autoscale_setting_resource + else: + _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: + """Lists the autoscale settings for a subscription. + + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_baselines_operations.py new file mode 100644 index 0000000000000..8eb076171b956 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_baselines_operations.py @@ -0,0 +1,177 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import datetime +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._baselines_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BaselinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`baselines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_uri: str, + metricnames: Optional[str] = None, + metricnamespace: Optional[str] = None, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, _models.ResultType]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SingleMetricBaseline"]: + """**Lists the metric baseline values for a resource**. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param metricnames: 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'**. Default value is None. + :type metricnames: str + :param metricnamespace: Metric namespace that contains the requested metric names. Default + value is None. + :type metricnamespace: str + :param timespan: The timespan of the query. It is a string with the following format + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. + :type timespan: str + :param interval: The interval (i.e. timegrain) of the query. Default value is None. + :type interval: ~datetime.timedelta + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. + :type aggregation: str + :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is + None. + :type sensitivities: str + :param filter: 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' "**. Default value is None. + :type filter: str + :param result_type: Allows retrieving only metadata of the baseline. On data request all + information is retrieved. Known values are: "Data" and "Metadata". Default value is None. + :type result_type: str or ~azure.mgmt.monitor.models.ResultType + :return: An iterator like instance of either SingleMetricBaseline or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.SingleMetricBaseline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + metricnames=metricnames, + metricnamespace=metricnamespace, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + filter=filter, + result_type=result_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_diagnostic_settings_category_operations.py new file mode 100644 index 0000000000000..c65e439b66f68 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_diagnostic_settings_category_operations.py @@ -0,0 +1,160 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DiagnosticSettingsCategoryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`diagnostic_settings_category` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: + """Gets the diagnostic settings category for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: DiagnosticSettingsCategoryResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsCategoryResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: + """Lists the diagnostic settings categories for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: DiagnosticSettingsCategoryResourceCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsCategoryResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "DiagnosticSettingsCategoryResourceCollection", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..01ff1f60c4dad --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_diagnostic_settings_operations.py @@ -0,0 +1,360 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`diagnostic_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: + """Gets the active diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_uri: str, + name: str, + parameters: _models.DiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_uri: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_uri: str, + name: str, + parameters: Union[_models.DiagnosticSettingsResource, IO[bytes]], + **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.DiagnosticSettingsResource or IO[bytes] + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticSettingsResource") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_uri: str, name: str, **kwargs: Any) -> None: + """Deletes existing diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.DiagnosticSettingsResource"]: + """Gets the active diagnostic settings list for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: An iterator like instance of either DiagnosticSettingsResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.DiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_event_categories_operations.py new file mode 100644 index 0000000000000..418414420b1c2 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_event_categories_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._event_categories_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EventCategoriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`event_categories` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.LocalizableString"]: + """Get the list of available event categories supported in the Activity Logs Service.\\ + :code:`
`The current list includes the following: Administrative, Security, ServiceHealth, + Alert, Recommendation, Policy. + + :return: An iterator like instance of either LocalizableString or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.LocalizableString] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventCategoryCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventCategoryCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_guest_diagnostics_settings_association_operations.py new file mode 100644 index 0000000000000..c58b14e41c4c0 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_guest_diagnostics_settings_association_operations.py @@ -0,0 +1,578 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._guest_diagnostics_settings_association_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GuestDiagnosticsSettingsAssociationOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings_association` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: + ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: Union[_models.GuestDiagnosticSettingsAssociationResource, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Is either a GuestDiagnosticSettingsAssociationResource type or a IO[bytes] type. + Required. + :type diagnostic_settings_association: + ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource or IO[bytes] + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings_association, (IOBase, bytes)): + _content = diagnostic_settings_association + else: + _json = self._serialize.body(diagnostic_settings_association, "GuestDiagnosticSettingsAssociationResource") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_uri: str, association_name: str, **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Gets guest diagnostics association settings. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_uri: str, association_name: str, **kwargs: Any) -> None: + """Delete guest diagnostics association settings. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def update( + self, + resource_uri: str, + association_name: str, + parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_uri: str, + association_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_uri: str, + association_name: str, + parameters: Union[_models.GuestDiagnosticSettingsAssociationResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Is either a + GuestDiagnosticSettingsAssociationResourcePatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResourcePatch or + IO[bytes] + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsAssociationResourcePatch") + + _request = build_update_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationResource"]: + """Get a list of all guest diagnostic settings association in a subscription. + + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationResource"]: + """Get a list of all guest diagnostic settings association in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_guest_diagnostics_settings_operations.py new file mode 100644 index 0000000000000..ae40d87883691 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_guest_diagnostics_settings_operations.py @@ -0,0 +1,574 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._guest_diagnostics_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GuestDiagnosticsSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: _models.GuestDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Required. + :type diagnostic_settings: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Required. + :type diagnostic_settings: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: Union[_models.GuestDiagnosticSettingsResource, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Is either a + GuestDiagnosticSettingsResource type or a IO[bytes] type. Required. + :type diagnostic_settings: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource or + IO[bytes] + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings, (IOBase, bytes)): + _content = diagnostic_settings + else: + _json = self._serialize.body(diagnostic_settings, "GuestDiagnosticSettingsResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Gets guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: _models.GuestDiagnosticSettingsPatchResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: Union[_models.GuestDiagnosticSettingsPatchResource, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Is either a GuestDiagnosticSettingsPatchResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsPatchResource or IO[bytes] + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsPatchResource") + + _request = build_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any) -> None: + """Delete guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsResource"]: + """Get a list of all guest diagnostic settings in a subscription. + + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GuestDiagnosticSettingsResource"]: + """Get a list of all guest diagnostic settings in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_log_profiles_operations.py new file mode 100644 index 0000000000000..fe7c3a40a8810 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_log_profiles_operations.py @@ -0,0 +1,451 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._log_profiles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LogProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`log_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def delete(self, log_profile_name: str, **kwargs: Any) -> None: + """Deletes the log profile. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: + """Gets the log profile. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) + + _request = build_get_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogProfileResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + log_profile_name: str, + parameters: _models.LogProfileResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.LogProfileResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, log_profile_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, log_profile_name: str, parameters: Union[_models.LogProfileResource, IO[bytes]], **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Is either a LogProfileResource type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.LogProfileResource or IO[bytes] + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogProfileResource") + + _request = build_create_or_update_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogProfileResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + log_profile_name: str, + log_profiles_resource: _models.LogProfileResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Required. + :type log_profiles_resource: ~azure.mgmt.monitor.models.LogProfileResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + log_profile_name: str, + log_profiles_resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Required. + :type log_profiles_resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + log_profile_name: str, + log_profiles_resource: Union[_models.LogProfileResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Is either a + LogProfileResourcePatch type or a IO[bytes] type. Required. + :type log_profiles_resource: ~azure.mgmt.monitor.models.LogProfileResourcePatch or IO[bytes] + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(log_profiles_resource, (IOBase, bytes)): + _content = log_profiles_resource + else: + _json = self._serialize.body(log_profiles_resource, "LogProfileResourcePatch") + + _request = build_update_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogProfileResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.LogProfileResource"]: + """List the log profiles. + + :return: An iterator like instance of either LogProfileResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.LogProfileResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LogProfileCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_alerts_operations.py new file mode 100644 index 0000000000000..f319f4fa29f8d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_alerts_operations.py @@ -0,0 +1,567 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._metric_alerts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MetricAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`metric_alerts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.MetricAlertResource"]: + """Retrieve alert rule definitions in a subscription. + + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MetricAlertResource"]: + """Retrieve alert rule definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: + """Retrieve an alert rule definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.MetricAlertResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResource, IO[bytes]], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a + MetricAlertResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResource or IO[bytes] + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.MetricAlertResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a MetricAlertResourcePatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResourcePatch or IO[bytes] + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResourcePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> None: + """Delete an alert rule definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_alerts_status_operations.py new file mode 100644 index 0000000000000..c50a0d27dd103 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_alerts_status_operations.py @@ -0,0 +1,172 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._metric_alerts_status_operations import build_list_by_name_request, build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MetricAlertsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`metric_alerts_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> _models.MetricAlertStatusCollection: + """Retrieve an alert rule status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: MetricAlertStatusCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertStatusCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_by_name( + self, resource_group_name: str, rule_name: str, status_name: str, **kwargs: Any + ) -> _models.MetricAlertStatusCollection: + """Retrieve an alert rule status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param status_name: The name of the status. Required. + :type status_name: str + :return: MetricAlertStatusCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertStatusCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) + + _request = build_list_by_name_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + status_name=status_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_definitions_operations.py new file mode 100644 index 0000000000000..440e3e5ffd3be --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_definitions_operations.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._metric_definitions_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MetricDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MetricDefinition"]: + """Lists the metric definitions for the resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. + :type metricnamespace: str + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + metricnamespace=metricnamespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_namespaces_operations.py new file mode 100644 index 0000000000000..c05042a348550 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metric_namespaces_operations.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._metric_namespaces_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MetricNamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`metric_namespaces` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_uri: str, start_time: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MetricNamespace"]: + """Lists the metric namespaces for the resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param start_time: The ISO 8601 conform Date start time from which to query for metric + namespaces. Default value is None. + :type start_time: str + :return: An iterator like instance of either MetricNamespace or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.MetricNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) + cls: ClsType[_models.MetricNamespaceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + start_time=start_time, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metrics_operations.py new file mode 100644 index 0000000000000..7f0e3942aeb0a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_metrics_operations.py @@ -0,0 +1,170 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._metrics_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MetricsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`metrics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, + resource_uri: str, + timespan: Optional[str] = None, + interval: Optional[str] = None, + metricnames: Optional[str] = None, + aggregation: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, _models.ResultType]] = None, + metricnamespace: Optional[str] = None, + **kwargs: Any + ) -> _models.Response: + """**Lists the metric values for a resource**. This API uses the `default ARM throttling limits + `_. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param timespan: The timespan of the query. It is a string with the following format + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. + :type timespan: str + :param interval: The interval (i.e. timegrain) of the query in ISO 8601 duration format. + Defaults to PT1M. Special case for 'FULL' value that returns single datapoint for entire time + span requested. + *Examples: PT15M, PT1H, P1D, FULL*. Default value is None. + :type interval: str + :param metricnames: The names of the metrics (comma separated) to retrieve. Limit 20 metrics. + Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: + 'Metric,Name1' should be **'Metric%2Name1'**. Default value is None. + :type metricnames: str + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. + :type aggregation: str + :param top: The maximum number of records to retrieve. + Valid only if $filter is specified. + Defaults to 10. Default value is None. + :type top: int + :param orderby: The aggregation to use for sorting results and the direction of the sort. + Only one order can be specified. + Examples: sum asc. Default value is None. + :type orderby: str + :param filter: 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' "**. Default value is None. + :type filter: str + :param result_type: Reduces the set of data collected. The syntax allowed depends on the + operation. See the operation's description for details. Known values are: "Data" and + "Metadata". Default value is None. + :type result_type: str or ~azure.mgmt.monitor.models.ResultType + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. + :type metricnamespace: str + :return: Response or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.Response + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.Response] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_uri=resource_uri, + timespan=timespan, + interval=interval, + metricnames=metricnames, + aggregation=aggregation, + top=top, + orderby=orderby, + filter=filter, + result_type=result_type, + metricnamespace=metricnamespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Response", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_operations.py new file mode 100644 index 0000000000000..bcc82c3a97c9d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.OperationListResult: + """Lists all of the available operations from Microsoft.Insights provider. + + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.OperationListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_patch.py similarity index 100% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_patch.py diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_predictive_metric_operations.py new file mode 100644 index 0000000000000..a0f924d38008b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_predictive_metric_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import datetime +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._predictive_metric_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PredictiveMetricOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`predictive_metric` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + autoscale_setting_name: str, + timespan: str, + interval: datetime.timedelta, + metric_namespace: str, + metric_name: str, + aggregation: str, + **kwargs: Any + ) -> _models.PredictiveResponse: + """get predictive autoscale metric future data. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param timespan: The timespan of the query. It is a string with the following format + 'startDateTime_ISO/endDateTime_ISO'. Required. + :type timespan: str + :param interval: The interval (i.e. timegrain) of the query. Required. + :type interval: ~datetime.timedelta + :param metric_namespace: Metric namespace to query metric definitions for. Required. + :type metric_namespace: str + :param metric_name: 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'**. Required. + :type metric_name: str + :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. + :type aggregation: str + :return: PredictiveResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.PredictiveResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + timespan=timespan, + interval=interval, + metric_namespace=metric_namespace, + metric_name=metric_name, + aggregation=aggregation, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredictiveResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 0000000000000..6c0a25377d14c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,514 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_private_link_scope_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.monitor.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.PrivateEndpointConnection or IO[bytes] + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """Gets all private endpoint connections on a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_resources_operations.py new file mode 100644 index 0000000000000..3024893be6aa1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,187 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scope_operation_status_operations.py new file mode 100644 index 0000000000000..d1e5f848f41cd --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scope_operation_status_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._private_link_scope_operation_status_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkScopeOperationStatusOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`private_link_scope_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: + """Get the status of an azure asynchronous operation associated with a private link scope + operation. + + :param async_operation_id: The operation Id. Required. + :type async_operation_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: OperationStatus or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.OperationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) + + _request = build_get_request( + async_operation_id=async_operation_id, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scoped_resources_operations.py new file mode 100644 index 0000000000000..5a280004f5463 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scoped_resources_operations.py @@ -0,0 +1,507 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._private_link_scoped_resources_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_private_link_scope_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkScopedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`private_link_scoped_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: + """Gets a scoped resource in a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :return: ScopedResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ScopedResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScopedResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: Union[_models.ScopedResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: _models.ScopedResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.monitor.models.ScopedResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: Union[_models.ScopedResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Is either a ScopedResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.ScopedResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopedResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ScopedResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ScopedResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ScopedResource"]: + """Gets all private endpoint connections on a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An iterator like instance of either ScopedResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scopes_operations.py new file mode 100644 index 0000000000000..de96c064e4159 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_private_link_scopes_operations.py @@ -0,0 +1,634 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._private_link_scopes_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_tags_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`private_link_scopes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: + """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: + """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _delete_initial(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Returns a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Required. + :type azure_monitor_private_link_scope_payload: + ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Required. + :type azure_monitor_private_link_scope_payload: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO[bytes]], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a + IO[bytes] type. Required. + :type azure_monitor_private_link_scope_payload: + ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope or IO[bytes] + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_monitor_private_link_scope_payload, (IOBase, bytes)): + _content = azure_monitor_private_link_scope_payload + else: + _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: ~azure.mgmt.monitor.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: Union[_models.TagsResource, IO[bytes]], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Is either a TagsResource type or a IO[bytes] type. Required. + :type private_link_scope_tags: ~azure.mgmt.monitor.models.TagsResource or IO[bytes] + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_scope_tags, (IOBase, bytes)): + _content = private_link_scope_tags + else: + _json = self._serialize.body(private_link_scope_tags, "TagsResource") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_scheduled_query_rules_operations.py new file mode 100644 index 0000000000000..6cf7788cbd270 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_scheduled_query_rules_operations.py @@ -0,0 +1,581 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._scheduled_query_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ScheduledQueryRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.LogSearchRuleResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResource, IO[bytes]], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a + LogSearchRuleResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResource or IO[bytes] + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: + """Gets an Log Search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.LogSearchRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a LogSearchRuleResourcePatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResourcePatch or IO[bytes] + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResourcePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> None: + """Deletes a Log Search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_subscription( + self, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.LogSearchRuleResource"]: + """List the Log Search rules within a subscription group. + + :param filter: The filter to apply on the operation. For more information please see + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. + :type filter: str + :return: An iterator like instance of either LogSearchRuleResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.LogSearchRuleResource"]: + """List the Log Search rules within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For more information please see + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. + :type filter: str + :return: An iterator like instance of either LogSearchRuleResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_service_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..5a465edfd910a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_service_diagnostic_settings_operations.py @@ -0,0 +1,343 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._service_diagnostic_settings_operations import ( + build_create_or_update_request, + build_get_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServiceDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`service_diagnostic_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: + """Gets the active diagnostic settings for the specified resource. **WARNING**\\ : This method + will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_uri: str, + parameters: _models.ServiceDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\\ : This + method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, resource_uri: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\\ : This + method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO[bytes]], **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\\ : This + method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource or IO[bytes] + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. + :type service_diagnostic_settings_resource: + ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. + :type service_diagnostic_settings_resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: Union[_models.ServiceDiagnosticSettingsResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResourcePatch type or a IO[bytes] type. Required. + :type service_diagnostic_settings_resource: + ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResourcePatch or IO[bytes] + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(service_diagnostic_settings_resource, (IOBase, bytes)): + _content = service_diagnostic_settings_resource + else: + _json = self._serialize.body(service_diagnostic_settings_resource, "ServiceDiagnosticSettingsResourcePatch") + + _request = build_update_request( + resource_uri=resource_uri, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_subscription_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..59939234d3fa3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_subscription_diagnostic_settings_operations.py @@ -0,0 +1,321 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._subscription_diagnostic_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SubscriptionDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`subscription_diagnostic_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: + """Gets the active subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + name: str, + parameters: _models.SubscriptionDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO[bytes]], **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a + SubscriptionDiagnosticSettingsResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource or + IO[bytes] + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") + + _request = build_create_or_update_request( + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, name: str, **kwargs: Any) -> None: + """Deletes existing subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: + """Gets the active subscription diagnostic settings list for the specified subscriptionId. + + :return: SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "SubscriptionDiagnosticSettingsResourceCollection", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_tenant_activity_logs_operations.py new file mode 100644 index 0000000000000..73807ff61209e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_tenant_activity_logs_operations.py @@ -0,0 +1,150 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._tenant_activity_logs_operations import build_list_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TenantActivityLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`tenant_activity_logs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventData"]: + """Gets the Activity Logs for the Tenant.\\ :code:`
`Everything that is applicable to the API + to get the Activity Logs for the subscription is applicable to this API (the parameters, + $filter, etc.).\\ :code:`
`One thing to point out here is that this API does *not* retrieve + the logs at the individual subscription of the tenant but only surfaces the logs that were + generated at the tenant level. + + :param filter: Reduces the set of data collected. :code:`
`The **$filter** is very + restricted and allows only the following patterns.\\ :code:`
`- List events for a resource + group: $filter=eventTimestamp ge '\\ :code:``' and eventTimestamp le '\\ + :code:``' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '\\ + :code:``'.\\ :code:`
`- List events for resource: $filter=eventTimestamp + ge '\\ :code:``' and eventTimestamp le '\\ :code:``' and eventChannels eq + 'Admin, Operation' and resourceUri eq '\\ :code:``'.\\ :code:`
`- List events + for a subscription: $filter=eventTimestamp ge '\\ :code:``' and eventTimestamp le + '\\ :code:``' and eventChannels eq 'Admin, Operation'.\\ :code:`
`- List events + for a resource provider: $filter=eventTimestamp ge '\\ :code:``' and eventTimestamp + le '\\ :code:``' and eventChannels eq 'Admin, Operation' and resourceProvider eq '\\ + :code:``'.\\ :code:`
`- List events for a correlation Id: + api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and + eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and + correlationId eq '\\ :code:``'.\\ :code:`
`\\ **NOTE**\\ : No other syntax is + allowed. Default value is None. + :type filter: str + :param select: Used to fetch events with only the given properties.\\ :code:`
`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*. Default value is None. + :type select: str + :return: An iterator like instance of either EventData or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + filter=filter, + select=select, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventDataCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_vm_insights_operations.py new file mode 100644 index 0000000000000..a29bca1663564 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/operations/_vm_insights_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ...operations._vm_insights_operations import build_get_onboarding_status_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class VMInsightsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.aio.MonitorManagementClient`'s + :attr:`vm_insights` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMInsightsOnboardingStatus: + """Retrieves the VM Insights onboarding status for the specified resource or resource scope. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or + scope, whose status to retrieve. Required. + :type resource_uri: str + :return: VMInsightsOnboardingStatus or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.VMInsightsOnboardingStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) + cls: ClsType[_models.VMInsightsOnboardingStatus] = kwargs.pop("cls", None) + + _request = build_get_onboarding_status_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VMInsightsOnboardingStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py deleted file mode 100644 index d64ede9d3004f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from .v2015_04_01.models import * -from .v2016_03_01.models import * -from .v2016_09_01.models import * -from .v2017_12_01_preview.models import * -from .v2018_03_01.models import * -from .v2018_04_16.models import * -from .v2018_06_01_preview.models import * -from .v2018_11_27_preview.models import * -from .v2019_03_01.models import * -from .v2019_10_17.models import * -from .v2020_10_01.models import * -from .v2021_05_01.models import * -from .v2021_05_01_preview.models import * -from .v2021_06_03_preview.models import * -from .v2022_06_01.models import * -from .v2022_10_01.models import * -from .v2023_01_01.models import * diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py new file mode 100644 index 0000000000000..2dee3ec988ded --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py @@ -0,0 +1,440 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + Action, + ActionDetail, + ActionGroupList, + ActionGroupPatchBody, + ActionGroupResource, + ActivityLogAlertActionGroup, + ActivityLogAlertActionList, + ActivityLogAlertAllOfCondition, + ActivityLogAlertLeafCondition, + ActivityLogAlertList, + ActivityLogAlertPatchBody, + ActivityLogAlertResource, + AlertingAction, + ArmRoleReceiver, + AutomationRunbookReceiver, + AutoscaleErrorResponse, + AutoscaleErrorResponseError, + AutoscaleNotification, + AutoscaleProfile, + AutoscaleSettingResource, + AutoscaleSettingResourceCollection, + AutoscaleSettingResourcePatch, + AzNsActionGroup, + AzureAppPushReceiver, + AzureFunctionReceiver, + AzureMonitorPrivateLinkScope, + AzureMonitorPrivateLinkScopeListResult, + AzureResource, + BaselineMetadata, + Context, + Criteria, + DataContainer, + DataSource, + DataSourceConfiguration, + DiagnosticSettingsCategoryResource, + DiagnosticSettingsCategoryResourceCollection, + DiagnosticSettingsResource, + DiagnosticSettingsResourceCollection, + Dimension, + DynamicMetricCriteria, + DynamicThresholdFailingPeriods, + EmailNotification, + EmailReceiver, + EnableRequest, + Error, + ErrorAdditionalInfo, + ErrorContract, + ErrorDetail, + ErrorDetailAdditionalInfoItem, + ErrorResponse, + ErrorResponseAutoGenerated, + ErrorResponseAutoGenerated2, + ErrorResponseCommon, + ErrorResponseError, + ErrorResponseErrorAdditionalInfoItem, + EtwEventConfiguration, + EtwProviderConfiguration, + EventCategoryCollection, + EventData, + EventDataCollection, + EventHubReceiver, + EventLogConfiguration, + GuestDiagnosticSettingsAssociationList, + GuestDiagnosticSettingsAssociationResource, + GuestDiagnosticSettingsAssociationResourcePatch, + GuestDiagnosticSettingsList, + GuestDiagnosticSettingsPatchResource, + GuestDiagnosticSettingsResource, + HttpRequestInfo, + Incident, + IncidentListResult, + ItsmReceiver, + LocalizableString, + LocalizableStringAutoGenerated, + LogMetricTrigger, + LogProfileCollection, + LogProfileResource, + LogProfileResourcePatch, + LogSearchRuleResource, + LogSearchRuleResourceCollection, + LogSearchRuleResourcePatch, + LogSettings, + LogSettingsAutoGenerated, + LogToMetricAction, + LogicAppReceiver, + MetadataValue, + Metric, + MetricAlertAction, + MetricAlertCriteria, + MetricAlertMultipleResourceMultipleMetricCriteria, + MetricAlertResource, + MetricAlertResourceCollection, + MetricAlertResourcePatch, + MetricAlertSingleResourceMultipleMetricCriteria, + MetricAlertStatus, + MetricAlertStatusCollection, + MetricAlertStatusProperties, + MetricAvailability, + MetricBaselinesResponse, + MetricCriteria, + MetricDefinition, + MetricDefinitionCollection, + MetricDimension, + MetricNamespace, + MetricNamespaceCollection, + MetricNamespaceName, + MetricSettings, + MetricSettingsAutoGenerated, + MetricSingleDimension, + MetricTrigger, + MetricValue, + MultiMetricCriteria, + NotificationRequestBody, + Operation, + OperationDisplay, + OperationListResult, + OperationStatus, + PerformanceCounterConfiguration, + PredictiveAutoscalePolicy, + PredictiveResponse, + PredictiveValue, + PrivateEndpointConnection, + PrivateEndpointConnectionListResult, + PrivateEndpointProperty, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkScopesResource, + PrivateLinkServiceConnectionStateProperty, + ProxyOnlyResource, + ProxyResource, + Recurrence, + RecurrentSchedule, + Resource, + ResourceAutoGenerated, + ResourceAutoGenerated2, + ResourceAutoGenerated3, + Response, + ResponseWithError, + RetentionPolicy, + ScaleAction, + ScaleCapacity, + ScaleRule, + ScaleRuleMetricDimension, + Schedule, + ScopedResource, + ScopedResourceListResult, + SenderAuthorization, + ServiceDiagnosticSettingsResource, + ServiceDiagnosticSettingsResourcePatch, + SingleBaseline, + SingleMetricBaseline, + SinkConfiguration, + SmsReceiver, + Source, + SubscriptionDiagnosticSettingsResource, + SubscriptionDiagnosticSettingsResourceCollection, + SubscriptionLogSettings, + SubscriptionProxyOnlyResource, + SystemData, + TagsResource, + TestNotificationDetailsResponse, + TimeSeriesBaseline, + TimeSeriesElement, + TimeWindow, + TriggerCondition, + VMInsightsOnboardingStatus, + VoiceReceiver, + WebhookNotification, + WebhookReceiver, + WebtestLocationAvailabilityCriteria, + WorkspaceInfo, +) + +from ._monitor_management_client_enums import ( # type: ignore + AggregationType, + AggregationTypeEnum, + AlertSeverity, + BaselineSensitivity, + CategoryType, + ComparisonOperationType, + ConditionalOperator, + CreatedByType, + CriterionType, + DataSourceKind, + DataStatus, + DynamicThresholdOperator, + DynamicThresholdSensitivity, + Enabled, + EventLevel, + GuestDiagnosticSettingsOsType, + MetricClass, + MetricStatisticType, + MetricTriggerType, + MetricUnit, + NamespaceClassification, + Odatatype, + OnboardingStatus, + Operator, + PredictiveAutoscalePolicyScaleMode, + ProvisioningState, + QueryType, + ReceiverStatus, + RecurrenceFrequency, + ResultType, + ScaleDirection, + ScaleRuleMetricDimensionOperationType, + ScaleType, + SinkConfigurationKind, + TimeAggregationType, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Action", + "ActionDetail", + "ActionGroupList", + "ActionGroupPatchBody", + "ActionGroupResource", + "ActivityLogAlertActionGroup", + "ActivityLogAlertActionList", + "ActivityLogAlertAllOfCondition", + "ActivityLogAlertLeafCondition", + "ActivityLogAlertList", + "ActivityLogAlertPatchBody", + "ActivityLogAlertResource", + "AlertingAction", + "ArmRoleReceiver", + "AutomationRunbookReceiver", + "AutoscaleErrorResponse", + "AutoscaleErrorResponseError", + "AutoscaleNotification", + "AutoscaleProfile", + "AutoscaleSettingResource", + "AutoscaleSettingResourceCollection", + "AutoscaleSettingResourcePatch", + "AzNsActionGroup", + "AzureAppPushReceiver", + "AzureFunctionReceiver", + "AzureMonitorPrivateLinkScope", + "AzureMonitorPrivateLinkScopeListResult", + "AzureResource", + "BaselineMetadata", + "Context", + "Criteria", + "DataContainer", + "DataSource", + "DataSourceConfiguration", + "DiagnosticSettingsCategoryResource", + "DiagnosticSettingsCategoryResourceCollection", + "DiagnosticSettingsResource", + "DiagnosticSettingsResourceCollection", + "Dimension", + "DynamicMetricCriteria", + "DynamicThresholdFailingPeriods", + "EmailNotification", + "EmailReceiver", + "EnableRequest", + "Error", + "ErrorAdditionalInfo", + "ErrorContract", + "ErrorDetail", + "ErrorDetailAdditionalInfoItem", + "ErrorResponse", + "ErrorResponseAutoGenerated", + "ErrorResponseAutoGenerated2", + "ErrorResponseCommon", + "ErrorResponseError", + "ErrorResponseErrorAdditionalInfoItem", + "EtwEventConfiguration", + "EtwProviderConfiguration", + "EventCategoryCollection", + "EventData", + "EventDataCollection", + "EventHubReceiver", + "EventLogConfiguration", + "GuestDiagnosticSettingsAssociationList", + "GuestDiagnosticSettingsAssociationResource", + "GuestDiagnosticSettingsAssociationResourcePatch", + "GuestDiagnosticSettingsList", + "GuestDiagnosticSettingsPatchResource", + "GuestDiagnosticSettingsResource", + "HttpRequestInfo", + "Incident", + "IncidentListResult", + "ItsmReceiver", + "LocalizableString", + "LocalizableStringAutoGenerated", + "LogMetricTrigger", + "LogProfileCollection", + "LogProfileResource", + "LogProfileResourcePatch", + "LogSearchRuleResource", + "LogSearchRuleResourceCollection", + "LogSearchRuleResourcePatch", + "LogSettings", + "LogSettingsAutoGenerated", + "LogToMetricAction", + "LogicAppReceiver", + "MetadataValue", + "Metric", + "MetricAlertAction", + "MetricAlertCriteria", + "MetricAlertMultipleResourceMultipleMetricCriteria", + "MetricAlertResource", + "MetricAlertResourceCollection", + "MetricAlertResourcePatch", + "MetricAlertSingleResourceMultipleMetricCriteria", + "MetricAlertStatus", + "MetricAlertStatusCollection", + "MetricAlertStatusProperties", + "MetricAvailability", + "MetricBaselinesResponse", + "MetricCriteria", + "MetricDefinition", + "MetricDefinitionCollection", + "MetricDimension", + "MetricNamespace", + "MetricNamespaceCollection", + "MetricNamespaceName", + "MetricSettings", + "MetricSettingsAutoGenerated", + "MetricSingleDimension", + "MetricTrigger", + "MetricValue", + "MultiMetricCriteria", + "NotificationRequestBody", + "Operation", + "OperationDisplay", + "OperationListResult", + "OperationStatus", + "PerformanceCounterConfiguration", + "PredictiveAutoscalePolicy", + "PredictiveResponse", + "PredictiveValue", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateEndpointProperty", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkScopesResource", + "PrivateLinkServiceConnectionStateProperty", + "ProxyOnlyResource", + "ProxyResource", + "Recurrence", + "RecurrentSchedule", + "Resource", + "ResourceAutoGenerated", + "ResourceAutoGenerated2", + "ResourceAutoGenerated3", + "Response", + "ResponseWithError", + "RetentionPolicy", + "ScaleAction", + "ScaleCapacity", + "ScaleRule", + "ScaleRuleMetricDimension", + "Schedule", + "ScopedResource", + "ScopedResourceListResult", + "SenderAuthorization", + "ServiceDiagnosticSettingsResource", + "ServiceDiagnosticSettingsResourcePatch", + "SingleBaseline", + "SingleMetricBaseline", + "SinkConfiguration", + "SmsReceiver", + "Source", + "SubscriptionDiagnosticSettingsResource", + "SubscriptionDiagnosticSettingsResourceCollection", + "SubscriptionLogSettings", + "SubscriptionProxyOnlyResource", + "SystemData", + "TagsResource", + "TestNotificationDetailsResponse", + "TimeSeriesBaseline", + "TimeSeriesElement", + "TimeWindow", + "TriggerCondition", + "VMInsightsOnboardingStatus", + "VoiceReceiver", + "WebhookNotification", + "WebhookReceiver", + "WebtestLocationAvailabilityCriteria", + "WorkspaceInfo", + "AggregationType", + "AggregationTypeEnum", + "AlertSeverity", + "BaselineSensitivity", + "CategoryType", + "ComparisonOperationType", + "ConditionalOperator", + "CreatedByType", + "CriterionType", + "DataSourceKind", + "DataStatus", + "DynamicThresholdOperator", + "DynamicThresholdSensitivity", + "Enabled", + "EventLevel", + "GuestDiagnosticSettingsOsType", + "MetricClass", + "MetricStatisticType", + "MetricTriggerType", + "MetricUnit", + "NamespaceClassification", + "Odatatype", + "OnboardingStatus", + "Operator", + "PredictiveAutoscalePolicyScaleMode", + "ProvisioningState", + "QueryType", + "ReceiverStatus", + "RecurrenceFrequency", + "ResultType", + "ScaleDirection", + "ScaleRuleMetricDimensionOperationType", + "ScaleType", + "SinkConfigurationKind", + "TimeAggregationType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_models_py3.py new file mode 100644 index 0000000000000..5b33091601990 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_models_py3.py @@ -0,0 +1,8756 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from .. import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore + +if TYPE_CHECKING: + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class Action(_serialization.Model): + """Action descriptor. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AlertingAction, LogToMetricAction + + All required parameters must be populated in order to send to server. + + :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. + Required. + :vartype odata_type: str + """ + + _validation = { + "odata_type": {"required": True}, + } + + _attribute_map = { + "odata_type": {"key": "odata\\.type", "type": "str"}, + } + + _subtype_map = { + "odata_type": { + "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction": "AlertingAction", + "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction": "LogToMetricAction", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.odata_type: Optional[str] = None + + +class ActionDetail(_serialization.Model): + """The action detail. + + :ivar mechanism_type: The mechanism type. + :vartype mechanism_type: str + :ivar name: The name of the action. + :vartype name: str + :ivar status: The status of the action. + :vartype status: str + :ivar sub_state: The substatus of the action. + :vartype sub_state: str + :ivar send_time: The send time. + :vartype send_time: str + :ivar detail: The detail of the friendly error message. + :vartype detail: str + """ + + _attribute_map = { + "mechanism_type": {"key": "MechanismType", "type": "str"}, + "name": {"key": "Name", "type": "str"}, + "status": {"key": "Status", "type": "str"}, + "sub_state": {"key": "SubState", "type": "str"}, + "send_time": {"key": "SendTime", "type": "str"}, + "detail": {"key": "Detail", "type": "str"}, + } + + def __init__( + self, + *, + mechanism_type: Optional[str] = None, + name: Optional[str] = None, + status: Optional[str] = None, + sub_state: Optional[str] = None, + send_time: Optional[str] = None, + detail: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword mechanism_type: The mechanism type. + :paramtype mechanism_type: str + :keyword name: The name of the action. + :paramtype name: str + :keyword status: The status of the action. + :paramtype status: str + :keyword sub_state: The substatus of the action. + :paramtype sub_state: str + :keyword send_time: The send time. + :paramtype send_time: str + :keyword detail: The detail of the friendly error message. + :paramtype detail: str + """ + super().__init__(**kwargs) + self.mechanism_type = mechanism_type + self.name = name + self.status = status + self.sub_state = sub_state + self.send_time = send_time + self.detail = detail + + +class ActionGroupList(_serialization.Model): + """A list of action groups. + + :ivar value: The list of action groups. + :vartype value: list[~azure.mgmt.monitor.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ActionGroupResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of action groups. + :paramtype value: list[~azure.mgmt.monitor.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ActionGroupPatchBody(_serialization.Model): + """An action group object for the body of patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :vartype enabled: bool + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.tags = tags + self.enabled = enabled + + +class AzureResource(_serialization.Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class ActionGroupResource(AzureResource): + """An action group resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~azure.mgmt.monitor.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~azure.mgmt.monitor.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~azure.mgmt.monitor.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~azure.mgmt.monitor.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~azure.mgmt.monitor.models.AzureAppPushReceiver] + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :vartype automation_runbook_receivers: + list[~azure.mgmt.monitor.models.AutomationRunbookReceiver] + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~azure.mgmt.monitor.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: list[~azure.mgmt.monitor.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this + action group. + :vartype azure_function_receivers: list[~azure.mgmt.monitor.models.AzureFunctionReceiver] + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :vartype arm_role_receivers: list[~azure.mgmt.monitor.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: list[~azure.mgmt.monitor.models.EventHubReceiver] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "group_short_name": {"max_length": 12}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "group_short_name": {"key": "properties.groupShortName", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": { + "key": "properties.automationRunbookReceivers", + "type": "[AutomationRunbookReceiver]", + }, + "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + group_short_name: Optional[str] = None, + enabled: bool = True, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, + arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, + event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~azure.mgmt.monitor.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~azure.mgmt.monitor.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: list[~azure.mgmt.monitor.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~azure.mgmt.monitor.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: list[~azure.mgmt.monitor.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~azure.mgmt.monitor.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~azure.mgmt.monitor.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: list[~azure.mgmt.monitor.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: list[~azure.mgmt.monitor.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: list[~azure.mgmt.monitor.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: list[~azure.mgmt.monitor.models.EventHubReceiver] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.group_short_name = group_short_name + self.enabled = enabled + self.email_receivers = email_receivers + self.sms_receivers = sms_receivers + self.webhook_receivers = webhook_receivers + self.itsm_receivers = itsm_receivers + self.azure_app_push_receivers = azure_app_push_receivers + self.automation_runbook_receivers = automation_runbook_receivers + self.voice_receivers = voice_receivers + self.logic_app_receivers = logic_app_receivers + self.azure_function_receivers = azure_function_receivers + self.arm_role_receivers = arm_role_receivers + self.event_hub_receivers = event_hub_receivers + + +class ActivityLogAlertActionGroup(_serialization.Model): + """A pointer to an Azure Action Group. + + All required parameters must be populated in order to send to server. + + :ivar action_group_id: The resourceId of the action group. This cannot be null or empty. + Required. + :vartype action_group_id: str + :ivar webhook_properties: the dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :vartype webhook_properties: dict[str, str] + """ + + _validation = { + "action_group_id": {"required": True}, + } + + _attribute_map = { + "action_group_id": {"key": "actionGroupId", "type": "str"}, + "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, + } + + def __init__( + self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: + """ + :keyword action_group_id: The resourceId of the action group. This cannot be null or empty. + Required. + :paramtype action_group_id: str + :keyword webhook_properties: the dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :paramtype webhook_properties: dict[str, str] + """ + super().__init__(**kwargs) + self.action_group_id = action_group_id + self.webhook_properties = webhook_properties + + +class ActivityLogAlertActionList(_serialization.Model): + """A list of activity log alert actions. + + :ivar action_groups: The list of activity log alerts. + :vartype action_groups: list[~azure.mgmt.monitor.models.ActivityLogAlertActionGroup] + """ + + _attribute_map = { + "action_groups": {"key": "actionGroups", "type": "[ActivityLogAlertActionGroup]"}, + } + + def __init__( + self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs: Any + ) -> None: + """ + :keyword action_groups: The list of activity log alerts. + :paramtype action_groups: list[~azure.mgmt.monitor.models.ActivityLogAlertActionGroup] + """ + super().__init__(**kwargs) + self.action_groups = action_groups + + +class ActivityLogAlertAllOfCondition(_serialization.Model): + """An Activity Log alert condition that is met when all its member conditions are met. + + All required parameters must be populated in order to send to server. + + :ivar all_of: The list of activity log alert conditions. Required. + :vartype all_of: list[~azure.mgmt.monitor.models.ActivityLogAlertLeafCondition] + """ + + _validation = { + "all_of": {"required": True}, + } + + _attribute_map = { + "all_of": {"key": "allOf", "type": "[ActivityLogAlertLeafCondition]"}, + } + + def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs: Any) -> None: + """ + :keyword all_of: The list of activity log alert conditions. Required. + :paramtype all_of: list[~azure.mgmt.monitor.models.ActivityLogAlertLeafCondition] + """ + super().__init__(**kwargs) + self.all_of = all_of + + +class ActivityLogAlertLeafCondition(_serialization.Model): + """An Activity Log alert condition that is met by comparing an activity log field and value. + + All required parameters must be populated in order to send to server. + + :ivar field: The name of the field that this condition will examine. The possible values for + this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or + anything beginning with 'properties.'. Required. + :vartype field: str + :ivar equals: The field value will be compared to this value (case-insensitive) to determine if + the condition is met. Required. + :vartype equals: str + """ + + _validation = { + "field": {"required": True}, + "equals": {"required": True}, + } + + _attribute_map = { + "field": {"key": "field", "type": "str"}, + "equals": {"key": "equals", "type": "str"}, + } + + def __init__(self, *, field: str, equals: str, **kwargs: Any) -> None: + """ + :keyword field: The name of the field that this condition will examine. The possible values for + this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or + anything beginning with 'properties.'. Required. + :paramtype field: str + :keyword equals: The field value will be compared to this value (case-insensitive) to determine + if the condition is met. Required. + :paramtype equals: str + """ + super().__init__(**kwargs) + self.field = field + self.equals = equals + + +class ActivityLogAlertList(_serialization.Model): + """A list of activity log alerts. + + :ivar value: The list of activity log alerts. + :vartype value: list[~azure.mgmt.monitor.models.ActivityLogAlertResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ActivityLogAlertResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of activity log alerts. + :paramtype value: list[~azure.mgmt.monitor.models.ActivityLogAlertResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ActivityLogAlertPatchBody(_serialization.Model): + """An activity log alert object for the body of patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert + is not enabled, then none of its actions will be activated. + :vartype enabled: bool + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.tags = tags + self.enabled = enabled + + +class Resource(_serialization.Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class ActivityLogAlertResource(Resource): + """An activity log alert resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to + activityLogs with resourceIds that fall under one of these prefixes. This list must include at + least one item. + :vartype scopes: list[str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert + is not enabled, then none of its actions will be activated. + :vartype enabled: bool + :ivar condition: The condition that will cause this alert to activate. + :vartype condition: ~azure.mgmt.monitor.models.ActivityLogAlertAllOfCondition + :ivar actions: The actions that will activate when the condition is met. + :vartype actions: ~azure.mgmt.monitor.models.ActivityLogAlertActionList + :ivar description: A description of this activity log alert. + :vartype description: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "ActivityLogAlertAllOfCondition"}, + "actions": {"key": "properties.actions", "type": "ActivityLogAlertActionList"}, + "description": {"key": "properties.description", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + scopes: Optional[List[str]] = None, + enabled: bool = True, + condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, + actions: Optional["_models.ActivityLogAlertActionList"] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply + to activityLogs with resourceIds that fall under one of these prefixes. This list must include + at least one item. + :paramtype scopes: list[str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + :keyword condition: The condition that will cause this alert to activate. + :paramtype condition: ~azure.mgmt.monitor.models.ActivityLogAlertAllOfCondition + :keyword actions: The actions that will activate when the condition is met. + :paramtype actions: ~azure.mgmt.monitor.models.ActivityLogAlertActionList + :keyword description: A description of this activity log alert. + :paramtype description: str + """ + super().__init__(location=location, tags=tags, **kwargs) + self.scopes = scopes + self.enabled = enabled + self.condition = condition + self.actions = actions + self.description = description + + +class AlertingAction(Action): + """Specify action need to be taken when rule type is Alert. + + All required parameters must be populated in order to send to server. + + :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. + Required. + :vartype odata_type: str + :ivar severity: Severity of the alert. Required. Known values are: "0", "1", "2", "3", and "4". + :vartype severity: str or ~azure.mgmt.monitor.models.AlertSeverity + :ivar azns_action: Azure action group reference. + :vartype azns_action: ~azure.mgmt.monitor.models.AzNsActionGroup + :ivar throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. + :vartype throttling_in_min: int + :ivar trigger: The trigger condition that results in the alert rule being. Required. + :vartype trigger: ~azure.mgmt.monitor.models.TriggerCondition + """ + + _validation = { + "odata_type": {"required": True}, + "severity": {"required": True}, + "trigger": {"required": True}, + } + + _attribute_map = { + "odata_type": {"key": "odata\\.type", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "azns_action": {"key": "aznsAction", "type": "AzNsActionGroup"}, + "throttling_in_min": {"key": "throttlingInMin", "type": "int"}, + "trigger": {"key": "trigger", "type": "TriggerCondition"}, + } + + def __init__( + self, + *, + severity: Union[str, "_models.AlertSeverity"], + trigger: "_models.TriggerCondition", + azns_action: Optional["_models.AzNsActionGroup"] = None, + throttling_in_min: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword severity: Severity of the alert. Required. Known values are: "0", "1", "2", "3", and + "4". + :paramtype severity: str or ~azure.mgmt.monitor.models.AlertSeverity + :keyword azns_action: Azure action group reference. + :paramtype azns_action: ~azure.mgmt.monitor.models.AzNsActionGroup + :keyword throttling_in_min: time (in minutes) for which Alerts should be throttled or + suppressed. + :paramtype throttling_in_min: int + :keyword trigger: The trigger condition that results in the alert rule being. Required. + :paramtype trigger: ~azure.mgmt.monitor.models.TriggerCondition + """ + super().__init__(**kwargs) + self.odata_type: str = ( + "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction" + ) + self.severity = severity + self.azns_action = azns_action + self.throttling_in_min = throttling_in_min + self.trigger = trigger + + +class ArmRoleReceiver(_serialization.Model): + """An arm role receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the arm role receiver. Names must be unique across all receivers within + an action group. Required. + :vartype name: str + :ivar role_id: The arm role id. Required. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + "name": {"required": True}, + "role_id": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + } + + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: + """ + :keyword name: The name of the arm role receiver. Names must be unique across all receivers + within an action group. Required. + :paramtype name: str + :keyword role_id: The arm role id. Required. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super().__init__(**kwargs) + self.name = name + self.role_id = role_id + self.use_common_alert_schema = use_common_alert_schema + + +class AutomationRunbookReceiver(_serialization.Model): + """The Azure Automation Runbook notification receiver. + + All required parameters must be populated in order to send to server. + + :ivar automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. + :vartype automation_account_id: str + :ivar runbook_name: The name for this runbook. Required. + :vartype runbook_name: str + :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + "automation_account_id": {"required": True}, + "runbook_name": {"required": True}, + "webhook_resource_id": {"required": True}, + "is_global_runbook": {"required": True}, + } + + _attribute_map = { + "automation_account_id": {"key": "automationAccountId", "type": "str"}, + "runbook_name": {"key": "runbookName", "type": "str"}, + "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, + "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + } + + def __init__( + self, + *, + automation_account_id: str, + runbook_name: str, + webhook_resource_id: str, + is_global_runbook: bool, + name: Optional[str] = None, + service_uri: Optional[str] = None, + use_common_alert_schema: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword automation_account_id: The Azure automation account Id which holds this runbook and + authenticate to Azure resource. Required. + :paramtype automation_account_id: str + :keyword runbook_name: The name for this runbook. Required. + :paramtype runbook_name: str + :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super().__init__(**kwargs) + self.automation_account_id = automation_account_id + self.runbook_name = runbook_name + self.webhook_resource_id = webhook_resource_id + self.is_global_runbook = is_global_runbook + self.name = name + self.service_uri = service_uri + self.use_common_alert_schema = use_common_alert_schema + + +class AutoscaleErrorResponse(_serialization.Model): + """Describes the format of Error response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.monitor.models.AutoscaleErrorResponseError + :ivar system_data: The system metadata related to the response. + :vartype system_data: ~azure.mgmt.monitor.models.SystemData + """ + + _validation = { + "system_data": {"readonly": True}, + } + + _attribute_map = { + "error": {"key": "error", "type": "AutoscaleErrorResponseError"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.monitor.models.AutoscaleErrorResponseError + """ + super().__init__(**kwargs) + self.error = error + self.system_data = None + + +class AutoscaleErrorResponseError(_serialization.Model): + """The error object. + + :ivar code: One of a server-defined set of error codes. + :vartype code: str + :ivar message: A human-readable representation of the error. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar details: A human-readable representation of the error's details. + :vartype details: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "str"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: One of a server-defined set of error codes. + :paramtype code: str + :keyword message: A human-readable representation of the error. + :paramtype message: str + :keyword target: The target of the particular error. + :paramtype target: str + :keyword details: A human-readable representation of the error's details. + :paramtype details: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class AutoscaleNotification(_serialization.Model): + """Autoscale notification. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar operation: the operation associated with the notification and its value must be "scale". + Required. Default value is "Scale". + :vartype operation: str + :ivar email: the email notification. + :vartype email: ~azure.mgmt.monitor.models.EmailNotification + :ivar webhooks: the collection of webhook notifications. + :vartype webhooks: list[~azure.mgmt.monitor.models.WebhookNotification] + """ + + _validation = { + "operation": {"required": True, "constant": True}, + } + + _attribute_map = { + "operation": {"key": "operation", "type": "str"}, + "email": {"key": "email", "type": "EmailNotification"}, + "webhooks": {"key": "webhooks", "type": "[WebhookNotification]"}, + } + + operation = "Scale" + + def __init__( + self, + *, + email: Optional["_models.EmailNotification"] = None, + webhooks: Optional[List["_models.WebhookNotification"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword email: the email notification. + :paramtype email: ~azure.mgmt.monitor.models.EmailNotification + :keyword webhooks: the collection of webhook notifications. + :paramtype webhooks: list[~azure.mgmt.monitor.models.WebhookNotification] + """ + super().__init__(**kwargs) + self.email = email + self.webhooks = webhooks + + +class AutoscaleProfile(_serialization.Model): + """Autoscale profile. + + All required parameters must be populated in order to send to server. + + :ivar name: the name of the profile. Required. + :vartype name: str + :ivar capacity: the number of instances that can be used during this profile. Required. + :vartype capacity: ~azure.mgmt.monitor.models.ScaleCapacity + :ivar rules: the collection of rules that provide the triggers and parameters for the scaling + action. A maximum of 10 rules can be specified. Required. + :vartype rules: list[~azure.mgmt.monitor.models.ScaleRule] + :ivar fixed_date: the specific date-time for the profile. This element is not used if the + Recurrence element is used. + :vartype fixed_date: ~azure.mgmt.monitor.models.TimeWindow + :ivar recurrence: the repeating times at which this profile begins. This element is not used if + the FixedDate element is used. + :vartype recurrence: ~azure.mgmt.monitor.models.Recurrence + """ + + _validation = { + "name": {"required": True}, + "capacity": {"required": True}, + "rules": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "ScaleCapacity"}, + "rules": {"key": "rules", "type": "[ScaleRule]"}, + "fixed_date": {"key": "fixedDate", "type": "TimeWindow"}, + "recurrence": {"key": "recurrence", "type": "Recurrence"}, + } + + def __init__( + self, + *, + name: str, + capacity: "_models.ScaleCapacity", + rules: List["_models.ScaleRule"], + fixed_date: Optional["_models.TimeWindow"] = None, + recurrence: Optional["_models.Recurrence"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: the name of the profile. Required. + :paramtype name: str + :keyword capacity: the number of instances that can be used during this profile. Required. + :paramtype capacity: ~azure.mgmt.monitor.models.ScaleCapacity + :keyword rules: the collection of rules that provide the triggers and parameters for the + scaling action. A maximum of 10 rules can be specified. Required. + :paramtype rules: list[~azure.mgmt.monitor.models.ScaleRule] + :keyword fixed_date: the specific date-time for the profile. This element is not used if the + Recurrence element is used. + :paramtype fixed_date: ~azure.mgmt.monitor.models.TimeWindow + :keyword recurrence: the repeating times at which this profile begins. This element is not used + if the FixedDate element is used. + :paramtype recurrence: ~azure.mgmt.monitor.models.Recurrence + """ + super().__init__(**kwargs) + self.name = name + self.capacity = capacity + self.rules = rules + self.fixed_date = fixed_date + self.recurrence = recurrence + + +class ResourceAutoGenerated(_serialization.Model): + """The autoscale setting resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :vartype tags: dict[str, str] + :ivar system_data: The system metadata related to the response. + :vartype system_data: ~azure.mgmt.monitor.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.system_data = None + + +class AutoscaleSettingResource(ResourceAutoGenerated): + """The autoscale setting resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :vartype tags: dict[str, str] + :ivar system_data: The system metadata related to the response. + :vartype system_data: ~azure.mgmt.monitor.models.SystemData + :ivar profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. Required. + :vartype profiles: list[~azure.mgmt.monitor.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: list[~azure.mgmt.monitor.models.AutoscaleNotification] + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'false'. + :vartype enabled: bool + :ivar predictive_autoscale_policy: the predictive autoscale policy mode. + :vartype predictive_autoscale_policy: ~azure.mgmt.monitor.models.PredictiveAutoscalePolicy + :ivar name_properties_name: the name of the autoscale setting. + :vartype name_properties_name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting + should be added to. + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should + be added to. + :vartype target_resource_location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "profiles": {"required": True, "max_items": 20, "min_items": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, + "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "predictive_autoscale_policy": { + "key": "properties.predictiveAutoscalePolicy", + "type": "PredictiveAutoscalePolicy", + }, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, + "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + profiles: List["_models.AutoscaleProfile"], + tags: Optional[Dict[str, str]] = None, + notifications: Optional[List["_models.AutoscaleNotification"]] = None, + enabled: bool = False, + predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, + name_properties_name: Optional[str] = None, + target_resource_uri: Optional[str] = None, + target_resource_location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :paramtype tags: dict[str, str] + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. Required. + :paramtype profiles: list[~azure.mgmt.monitor.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: list[~azure.mgmt.monitor.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'false'. + :paramtype enabled: bool + :keyword predictive_autoscale_policy: the predictive autoscale policy mode. + :paramtype predictive_autoscale_policy: ~azure.mgmt.monitor.models.PredictiveAutoscalePolicy + :keyword name_properties_name: the name of the autoscale setting. + :paramtype name_properties_name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ + super().__init__(location=location, tags=tags, **kwargs) + self.profiles = profiles + self.notifications = notifications + self.enabled = enabled + self.predictive_autoscale_policy = predictive_autoscale_policy + self.name_properties_name = name_properties_name + self.target_resource_uri = target_resource_uri + self.target_resource_location = target_resource_location + + +class AutoscaleSettingResourceCollection(_serialization.Model): + """Represents a collection of autoscale setting resources. + + All required parameters must be populated in order to send to server. + + :ivar value: the values for the autoscale setting resources. Required. + :vartype value: list[~azure.mgmt.monitor.models.AutoscaleSettingResource] + :ivar next_link: URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AutoscaleSettingResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: the values for the autoscale setting resources. Required. + :paramtype value: list[~azure.mgmt.monitor.models.AutoscaleSettingResource] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AutoscaleSettingResourcePatch(_serialization.Model): + """The autoscale setting object for patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. + :vartype profiles: list[~azure.mgmt.monitor.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: list[~azure.mgmt.monitor.models.AutoscaleNotification] + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'false'. + :vartype enabled: bool + :ivar predictive_autoscale_policy: the predictive autoscale policy mode. + :vartype predictive_autoscale_policy: ~azure.mgmt.monitor.models.PredictiveAutoscalePolicy + :ivar name: the name of the autoscale setting. + :vartype name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting + should be added to. + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should + be added to. + :vartype target_resource_location: str + """ + + _validation = { + "profiles": {"max_items": 20, "min_items": 0}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, + "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "predictive_autoscale_policy": { + "key": "properties.predictiveAutoscalePolicy", + "type": "PredictiveAutoscalePolicy", + }, + "name": {"key": "properties.name", "type": "str"}, + "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, + "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + profiles: Optional[List["_models.AutoscaleProfile"]] = None, + notifications: Optional[List["_models.AutoscaleNotification"]] = None, + enabled: bool = False, + predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, + name: Optional[str] = None, + target_resource_uri: Optional[str] = None, + target_resource_location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. + :paramtype profiles: list[~azure.mgmt.monitor.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: list[~azure.mgmt.monitor.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'false'. + :paramtype enabled: bool + :keyword predictive_autoscale_policy: the predictive autoscale policy mode. + :paramtype predictive_autoscale_policy: ~azure.mgmt.monitor.models.PredictiveAutoscalePolicy + :keyword name: the name of the autoscale setting. + :paramtype name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.profiles = profiles + self.notifications = notifications + self.enabled = enabled + self.predictive_autoscale_policy = predictive_autoscale_policy + self.name = name + self.target_resource_uri = target_resource_uri + self.target_resource_location = target_resource_location + + +class AzNsActionGroup(_serialization.Model): + """Azure action group. + + :ivar action_group: Azure Action Group reference. + :vartype action_group: list[str] + :ivar email_subject: Custom subject override for all email ids in Azure action group. + :vartype email_subject: str + :ivar custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action + group. + :vartype custom_webhook_payload: str + """ + + _attribute_map = { + "action_group": {"key": "actionGroup", "type": "[str]"}, + "email_subject": {"key": "emailSubject", "type": "str"}, + "custom_webhook_payload": {"key": "customWebhookPayload", "type": "str"}, + } + + def __init__( + self, + *, + action_group: Optional[List[str]] = None, + email_subject: Optional[str] = None, + custom_webhook_payload: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword action_group: Azure Action Group reference. + :paramtype action_group: list[str] + :keyword email_subject: Custom subject override for all email ids in Azure action group. + :paramtype email_subject: str + :keyword custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action + group. + :paramtype custom_webhook_payload: str + """ + super().__init__(**kwargs) + self.action_group = action_group + self.email_subject = email_subject + self.custom_webhook_payload = custom_webhook_payload + + +class AzureAppPushReceiver(_serialization.Model): + """The Azure mobile App push notification receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. + :vartype name: str + :ivar email_address: The email address registered for the Azure mobile app. Required. + :vartype email_address: str + """ + + _validation = { + "name": {"required": True}, + "email_address": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + } + + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: + """ + :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all + receivers within an action group. Required. + :paramtype name: str + :keyword email_address: The email address registered for the Azure mobile app. Required. + :paramtype email_address: str + """ + super().__init__(**kwargs) + self.name = name + self.email_address = email_address + + +class AzureFunctionReceiver(_serialization.Model): + """An azure function receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the azure function receiver. Names must be unique across all receivers + within an action group. Required. + :vartype name: str + :ivar function_app_resource_id: The azure resource id of the function app. Required. + :vartype function_app_resource_id: str + :ivar function_name: The function name in the function app. Required. + :vartype function_name: str + :ivar http_trigger_url: The http trigger url where http request sent to. Required. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + "name": {"required": True}, + "function_app_resource_id": {"required": True}, + "function_name": {"required": True}, + "http_trigger_url": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, + "function_name": {"key": "functionName", "type": "str"}, + "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + function_app_resource_id: str, + function_name: str, + http_trigger_url: str, + use_common_alert_schema: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the azure function receiver. Names must be unique across all + receivers within an action group. Required. + :paramtype name: str + :keyword function_app_resource_id: The azure resource id of the function app. Required. + :paramtype function_app_resource_id: str + :keyword function_name: The function name in the function app. Required. + :paramtype function_name: str + :keyword http_trigger_url: The http trigger url where http request sent to. Required. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super().__init__(**kwargs) + self.name = name + self.function_app_resource_id = function_app_resource_id + self.function_name = function_name + self.http_trigger_url = http_trigger_url + self.use_common_alert_schema = use_common_alert_schema + + +class PrivateLinkScopesResource(_serialization.Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): + """An Azure Monitor PrivateLinkScope definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar provisioning_state: 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. + :vartype provisioning_state: str + :ivar private_endpoint_connections: List of private endpoint connections. + :vartype private_endpoint_connections: + list[~azure.mgmt.monitor.models.PrivateEndpointConnection] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.provisioning_state = None + self.private_endpoint_connections = None + + +class AzureMonitorPrivateLinkScopeListResult(_serialization.Model): + """Describes the list of Azure Monitor PrivateLinkScope resources. + + All required parameters must be populated in order to send to server. + + :ivar value: List of Azure Monitor PrivateLinkScope definitions. Required. + :vartype value: list[~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope] + :ivar next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if + too many PrivateLinkScopes where returned in the result set. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AzureMonitorPrivateLinkScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.AzureMonitorPrivateLinkScope"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: List of Azure Monitor PrivateLinkScope definitions. Required. + :paramtype value: list[~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope] + :keyword next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions + if too many PrivateLinkScopes where returned in the result set. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BaselineMetadata(_serialization.Model): + """Represents a baseline metadata value. + + All required parameters must be populated in order to send to server. + + :ivar name: Name of the baseline metadata. Required. + :vartype name: str + :ivar value: Value of the baseline metadata. Required. + :vartype value: str + """ + + _validation = { + "name": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: + """ + :keyword name: Name of the baseline metadata. Required. + :paramtype name: str + :keyword value: Value of the baseline metadata. Required. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class Context(_serialization.Model): + """The context info. + + :ivar notification_source: The source of the notification request. + :vartype notification_source: str + :ivar context_type: The context id type. + :vartype context_type: str + """ + + _attribute_map = { + "notification_source": {"key": "notificationSource", "type": "str"}, + "context_type": {"key": "contextType", "type": "str"}, + } + + def __init__( + self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword notification_source: The source of the notification request. + :paramtype notification_source: str + :keyword context_type: The context id type. + :paramtype context_type: str + """ + super().__init__(**kwargs) + self.notification_source = notification_source + self.context_type = context_type + + +class Criteria(_serialization.Model): + """Specifies the criteria for converting log to metric. + + All required parameters must be populated in order to send to server. + + :ivar metric_name: Name of the metric. Required. + :vartype metric_name: str + :ivar dimensions: List of Dimensions for creating metric. + :vartype dimensions: list[~azure.mgmt.monitor.models.Dimension] + """ + + _validation = { + "metric_name": {"required": True}, + } + + _attribute_map = { + "metric_name": {"key": "metricName", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + } + + def __init__( + self, *, metric_name: str, dimensions: Optional[List["_models.Dimension"]] = None, **kwargs: Any + ) -> None: + """ + :keyword metric_name: Name of the metric. Required. + :paramtype metric_name: str + :keyword dimensions: List of Dimensions for creating metric. + :paramtype dimensions: list[~azure.mgmt.monitor.models.Dimension] + """ + super().__init__(**kwargs) + self.metric_name = metric_name + self.dimensions = dimensions + + +class DataContainer(_serialization.Model): + """Information about a container with data for a given resource. + + All required parameters must be populated in order to send to server. + + :ivar workspace: Log Analytics workspace information. Required. + :vartype workspace: ~azure.mgmt.monitor.models.WorkspaceInfo + """ + + _validation = { + "workspace": {"required": True}, + } + + _attribute_map = { + "workspace": {"key": "workspace", "type": "WorkspaceInfo"}, + } + + def __init__(self, *, workspace: "_models.WorkspaceInfo", **kwargs: Any) -> None: + """ + :keyword workspace: Log Analytics workspace information. Required. + :paramtype workspace: ~azure.mgmt.monitor.models.WorkspaceInfo + """ + super().__init__(**kwargs) + self.workspace = workspace + + +class DataSource(_serialization.Model): + """Data source object contains configuration to collect telemetry and one or more sinks to send + that telemetry data to. + + All required parameters must be populated in order to send to server. + + :ivar kind: Datasource kind. Required. Known values are: "PerformanceCounter", "ETWProviders", + and "WindowsEventLogs". + :vartype kind: str or ~azure.mgmt.monitor.models.DataSourceKind + :ivar configuration: Required. + :vartype configuration: ~azure.mgmt.monitor.models.DataSourceConfiguration + :ivar sinks: Required. + :vartype sinks: list[~azure.mgmt.monitor.models.SinkConfiguration] + """ + + _validation = { + "kind": {"required": True}, + "configuration": {"required": True}, + "sinks": {"required": True}, + } + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + "configuration": {"key": "configuration", "type": "DataSourceConfiguration"}, + "sinks": {"key": "sinks", "type": "[SinkConfiguration]"}, + } + + def __init__( + self, + *, + kind: Union[str, "_models.DataSourceKind"], + configuration: "_models.DataSourceConfiguration", + sinks: List["_models.SinkConfiguration"], + **kwargs: Any + ) -> None: + """ + :keyword kind: Datasource kind. Required. Known values are: "PerformanceCounter", + "ETWProviders", and "WindowsEventLogs". + :paramtype kind: str or ~azure.mgmt.monitor.models.DataSourceKind + :keyword configuration: Required. + :paramtype configuration: ~azure.mgmt.monitor.models.DataSourceConfiguration + :keyword sinks: Required. + :paramtype sinks: list[~azure.mgmt.monitor.models.SinkConfiguration] + """ + super().__init__(**kwargs) + self.kind = kind + self.configuration = configuration + self.sinks = sinks + + +class DataSourceConfiguration(_serialization.Model): + """DataSourceConfiguration. + + :ivar providers: ETW providers configuration. + :vartype providers: list[~azure.mgmt.monitor.models.EtwProviderConfiguration] + :ivar perf_counters: Performance counter configuration. + :vartype perf_counters: list[~azure.mgmt.monitor.models.PerformanceCounterConfiguration] + :ivar event_logs: Windows event logs configuration. + :vartype event_logs: list[~azure.mgmt.monitor.models.EventLogConfiguration] + """ + + _attribute_map = { + "providers": {"key": "providers", "type": "[EtwProviderConfiguration]"}, + "perf_counters": {"key": "perfCounters", "type": "[PerformanceCounterConfiguration]"}, + "event_logs": {"key": "eventLogs", "type": "[EventLogConfiguration]"}, + } + + def __init__( + self, + *, + providers: Optional[List["_models.EtwProviderConfiguration"]] = None, + perf_counters: Optional[List["_models.PerformanceCounterConfiguration"]] = None, + event_logs: Optional[List["_models.EventLogConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword providers: ETW providers configuration. + :paramtype providers: list[~azure.mgmt.monitor.models.EtwProviderConfiguration] + :keyword perf_counters: Performance counter configuration. + :paramtype perf_counters: list[~azure.mgmt.monitor.models.PerformanceCounterConfiguration] + :keyword event_logs: Windows event logs configuration. + :paramtype event_logs: list[~azure.mgmt.monitor.models.EventLogConfiguration] + """ + super().__init__(**kwargs) + self.providers = providers + self.perf_counters = perf_counters + self.event_logs = event_logs + + +class ProxyOnlyResource(_serialization.Model): + """A proxy only azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class DiagnosticSettingsCategoryResource(ProxyOnlyResource): + """The diagnostic settings category resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics" + and "Logs". + :vartype category_type: str or ~azure.mgmt.monitor.models.CategoryType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "category_type": {"key": "properties.categoryType", "type": "str"}, + } + + def __init__(self, *, category_type: Optional[Union[str, "_models.CategoryType"]] = None, **kwargs: Any) -> None: + """ + :keyword category_type: The type of the diagnostic settings category. Known values are: + "Metrics" and "Logs". + :paramtype category_type: str or ~azure.mgmt.monitor.models.CategoryType + """ + super().__init__(**kwargs) + self.category_type = category_type + + +class DiagnosticSettingsCategoryResourceCollection(_serialization.Model): # pylint: disable=name-too-long + """Represents a collection of diagnostic setting category resources. + + :ivar value: The collection of diagnostic settings category resources. + :vartype value: list[~azure.mgmt.monitor.models.DiagnosticSettingsCategoryResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DiagnosticSettingsCategoryResource]"}, + } + + def __init__( + self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The collection of diagnostic settings category resources. + :paramtype value: list[~azure.mgmt.monitor.models.DiagnosticSettingsCategoryResource] + """ + super().__init__(**kwargs) + self.value = value + + +class ResourceAutoGenerated2(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class DiagnosticSettingsResource(ResourceAutoGenerated2): + """The diagnostic setting resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata related to this resource. + :vartype system_data: ~azure.mgmt.monitor.models.SystemData + :ivar storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + maintain backwards compatibility. + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :vartype event_hub_name: str + :ivar metrics: The list of metric settings. + :vartype metrics: list[~azure.mgmt.monitor.models.MetricSettings] + :ivar logs: The list of logs settings. + :vartype logs: list[~azure.mgmt.monitor.models.LogSettings] + :ivar workspace_id: 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. # pylint: disable=line-too-long + :vartype workspace_id: str + :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you + would like to send Diagnostic Logs. + :vartype marketplace_partner_id: str + :ivar log_analytics_destination_type: 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: :code:``_\\ :code:``. Possible values are: Dedicated and null (null is default.). + :vartype log_analytics_destination_type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, + "logs": {"key": "properties.logs", "type": "[LogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + "marketplace_partner_id": {"key": "properties.marketplacePartnerId", "type": "str"}, + "log_analytics_destination_type": {"key": "properties.logAnalyticsDestinationType", "type": "str"}, + } + + def __init__( + self, + *, + storage_account_id: Optional[str] = None, + service_bus_rule_id: Optional[str] = None, + event_hub_authorization_rule_id: Optional[str] = None, + event_hub_name: Optional[str] = None, + metrics: Optional[List["_models.MetricSettings"]] = None, + logs: Optional[List["_models.LogSettings"]] = None, + workspace_id: Optional[str] = None, + marketplace_partner_id: Optional[str] = None, + log_analytics_destination_type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword metrics: The list of metric settings. + :paramtype metrics: list[~azure.mgmt.monitor.models.MetricSettings] + :keyword logs: The list of logs settings. + :paramtype logs: list[~azure.mgmt.monitor.models.LogSettings] + :keyword workspace_id: 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. # pylint: disable=line-too-long + :paramtype workspace_id: str + :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which + you would like to send Diagnostic Logs. + :paramtype marketplace_partner_id: str + :keyword log_analytics_destination_type: 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: :code:``_\\ :code:``. Possible values are: Dedicated and null (null is default.). + :paramtype log_analytics_destination_type: str + """ + super().__init__(**kwargs) + self.system_data = None + self.storage_account_id = storage_account_id + self.service_bus_rule_id = service_bus_rule_id + self.event_hub_authorization_rule_id = event_hub_authorization_rule_id + self.event_hub_name = event_hub_name + self.metrics = metrics + self.logs = logs + self.workspace_id = workspace_id + self.marketplace_partner_id = marketplace_partner_id + self.log_analytics_destination_type = log_analytics_destination_type + + +class DiagnosticSettingsResourceCollection(_serialization.Model): + """Represents a collection of alert rule resources. + + :ivar value: The collection of diagnostic settings resources;. + :vartype value: list[~azure.mgmt.monitor.models.DiagnosticSettingsResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DiagnosticSettingsResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The collection of diagnostic settings resources;. + :paramtype value: list[~azure.mgmt.monitor.models.DiagnosticSettingsResource] + """ + super().__init__(**kwargs) + self.value = value + + +class Dimension(_serialization.Model): + """Specifies the criteria for converting log to metric. + + All required parameters must be populated in order to send to server. + + :ivar name: Name of the dimension. Required. + :vartype name: str + :ivar operator: Operator for dimension values. Required. Known values are: "Equals", + "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual", and "Include". + :vartype operator: str or ~azure.mgmt.monitor.models.Operator + :ivar values: List of dimension values. Required. + :vartype values: list[str] + """ + + _validation = { + "name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + } + + def __init__( + self, *, name: str, operator: Union[str, "_models.Operator"], values: List[str], **kwargs: Any + ) -> None: + """ + :keyword name: Name of the dimension. Required. + :paramtype name: str + :keyword operator: Operator for dimension values. Required. Known values are: "Equals", + "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual", and "Include". + :paramtype operator: str or ~azure.mgmt.monitor.models.Operator + :keyword values: List of dimension values. Required. + :paramtype values: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.operator = operator + self.values = values + + +class MultiMetricCriteria(_serialization.Model): + """The types of conditions for a multi resource alert. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DynamicMetricCriteria, MetricCriteria + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: + "StaticThresholdCriterion" and "DynamicThresholdCriterion". + :vartype criterion_type: str or ~azure.mgmt.monitor.models.CriterionType + :ivar name: Name of the criteria. Required. + :vartype name: str + :ivar metric_name: Name of the metric. Required. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". + :vartype time_aggregation: str or ~azure.mgmt.monitor.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~azure.mgmt.monitor.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + emitted, by causing the metric validation to be skipped. + :vartype skip_metric_validation: bool + """ + + _validation = { + "criterion_type": {"required": True}, + "name": {"required": True}, + "metric_name": {"required": True}, + "time_aggregation": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "criterion_type": {"key": "criterionType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, + } + + _subtype_map = { + "criterion_type": { + "DynamicThresholdCriterion": "DynamicMetricCriteria", + "StaticThresholdCriterion": "MetricCriteria", + } + } + + def __init__( + self, + *, + name: str, + metric_name: str, + time_aggregation: Union[str, "_models.AggregationTypeEnum"], + additional_properties: Optional[Dict[str, JSON]] = None, + metric_namespace: Optional[str] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, + skip_metric_validation: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + :keyword name: Name of the criteria. Required. + :paramtype name: str + :keyword metric_name: Name of the metric. Required. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". + :paramtype time_aggregation: str or ~azure.mgmt.monitor.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~azure.mgmt.monitor.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.criterion_type: Optional[str] = None + self.name = name + self.metric_name = metric_name + self.metric_namespace = metric_namespace + self.time_aggregation = time_aggregation + self.dimensions = dimensions + self.skip_metric_validation = skip_metric_validation + + +class DynamicMetricCriteria(MultiMetricCriteria): + """Criterion for dynamic threshold. + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: + "StaticThresholdCriterion" and "DynamicThresholdCriterion". + :vartype criterion_type: str or ~azure.mgmt.monitor.models.CriterionType + :ivar name: Name of the criteria. Required. + :vartype name: str + :ivar metric_name: Name of the metric. Required. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". + :vartype time_aggregation: str or ~azure.mgmt.monitor.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~azure.mgmt.monitor.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + emitted, by causing the metric validation to be skipped. + :vartype skip_metric_validation: bool + :ivar operator: The operator used to compare the metric value against the threshold. Required. + Known values are: "GreaterThan", "LessThan", and "GreaterOrLessThan". + :vartype operator: str or ~azure.mgmt.monitor.models.DynamicThresholdOperator + :ivar alert_sensitivity: The extent of deviation required to trigger an alert. This will affect + how tight the threshold is to the metric series pattern. Required. Known values are: "Low", + "Medium", and "High". + :vartype alert_sensitivity: str or ~azure.mgmt.monitor.models.DynamicThresholdSensitivity + :ivar failing_periods: The minimum number of violations required within the selected lookback + time window required to raise an alert. Required. + :vartype failing_periods: ~azure.mgmt.monitor.models.DynamicThresholdFailingPeriods + :ivar ignore_data_before: Use this option to set the date from which to start learning the + metric historical data and calculate the dynamic thresholds (in ISO8601 format). + :vartype ignore_data_before: ~datetime.datetime + """ + + _validation = { + "criterion_type": {"required": True}, + "name": {"required": True}, + "metric_name": {"required": True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "alert_sensitivity": {"required": True}, + "failing_periods": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "criterion_type": {"key": "criterionType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, + "operator": {"key": "operator", "type": "str"}, + "alert_sensitivity": {"key": "alertSensitivity", "type": "str"}, + "failing_periods": {"key": "failingPeriods", "type": "DynamicThresholdFailingPeriods"}, + "ignore_data_before": {"key": "ignoreDataBefore", "type": "iso-8601"}, + } + + def __init__( + self, + *, + name: str, + metric_name: str, + time_aggregation: Union[str, "_models.AggregationTypeEnum"], + operator: Union[str, "_models.DynamicThresholdOperator"], + alert_sensitivity: Union[str, "_models.DynamicThresholdSensitivity"], + failing_periods: "_models.DynamicThresholdFailingPeriods", + additional_properties: Optional[Dict[str, JSON]] = None, + metric_namespace: Optional[str] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, + skip_metric_validation: Optional[bool] = None, + ignore_data_before: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + :keyword name: Name of the criteria. Required. + :paramtype name: str + :keyword metric_name: Name of the metric. Required. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". + :paramtype time_aggregation: str or ~azure.mgmt.monitor.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~azure.mgmt.monitor.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + :keyword operator: The operator used to compare the metric value against the threshold. + Required. Known values are: "GreaterThan", "LessThan", and "GreaterOrLessThan". + :paramtype operator: str or ~azure.mgmt.monitor.models.DynamicThresholdOperator + :keyword alert_sensitivity: The extent of deviation required to trigger an alert. This will + affect how tight the threshold is to the metric series pattern. Required. Known values are: + "Low", "Medium", and "High". + :paramtype alert_sensitivity: str or ~azure.mgmt.monitor.models.DynamicThresholdSensitivity + :keyword failing_periods: The minimum number of violations required within the selected + lookback time window required to raise an alert. Required. + :paramtype failing_periods: ~azure.mgmt.monitor.models.DynamicThresholdFailingPeriods + :keyword ignore_data_before: Use this option to set the date from which to start learning the + metric historical data and calculate the dynamic thresholds (in ISO8601 format). + :paramtype ignore_data_before: ~datetime.datetime + """ + super().__init__( + additional_properties=additional_properties, + name=name, + metric_name=metric_name, + metric_namespace=metric_namespace, + time_aggregation=time_aggregation, + dimensions=dimensions, + skip_metric_validation=skip_metric_validation, + **kwargs + ) + self.criterion_type: str = "DynamicThresholdCriterion" + self.operator = operator + self.alert_sensitivity = alert_sensitivity + self.failing_periods = failing_periods + self.ignore_data_before = ignore_data_before + + +class DynamicThresholdFailingPeriods(_serialization.Model): + """The minimum number of violations required within the selected lookback time window required to + raise an alert. + + All required parameters must be populated in order to send to server. + + :ivar number_of_evaluation_periods: 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. Required. + :vartype number_of_evaluation_periods: float + :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Required. + :vartype min_failing_periods_to_alert: float + """ + + _validation = { + "number_of_evaluation_periods": {"required": True}, + "min_failing_periods_to_alert": {"required": True}, + } + + _attribute_map = { + "number_of_evaluation_periods": {"key": "numberOfEvaluationPeriods", "type": "float"}, + "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "float"}, + } + + def __init__( + self, *, number_of_evaluation_periods: float, min_failing_periods_to_alert: float, **kwargs: Any + ) -> None: + """ + :keyword number_of_evaluation_periods: 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. Required. + :paramtype number_of_evaluation_periods: float + :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Required. + :paramtype min_failing_periods_to_alert: float + """ + super().__init__(**kwargs) + self.number_of_evaluation_periods = number_of_evaluation_periods + self.min_failing_periods_to_alert = min_failing_periods_to_alert + + +class EmailNotification(_serialization.Model): + """Email notification of an autoscale event. + + :ivar send_to_subscription_administrator: a value indicating whether to send email to + subscription administrator. + :vartype send_to_subscription_administrator: bool + :ivar send_to_subscription_co_administrators: a value indicating whether to send email to + subscription co-administrators. + :vartype send_to_subscription_co_administrators: bool + :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case + this attribute will be ignored. + :vartype custom_emails: list[str] + """ + + _attribute_map = { + "send_to_subscription_administrator": {"key": "sendToSubscriptionAdministrator", "type": "bool"}, + "send_to_subscription_co_administrators": {"key": "sendToSubscriptionCoAdministrators", "type": "bool"}, + "custom_emails": {"key": "customEmails", "type": "[str]"}, + } + + def __init__( + self, + *, + send_to_subscription_administrator: bool = False, + send_to_subscription_co_administrators: bool = False, + custom_emails: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword send_to_subscription_administrator: a value indicating whether to send email to + subscription administrator. + :paramtype send_to_subscription_administrator: bool + :keyword send_to_subscription_co_administrators: a value indicating whether to send email to + subscription co-administrators. + :paramtype send_to_subscription_co_administrators: bool + :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case + this attribute will be ignored. + :paramtype custom_emails: list[str] + """ + super().__init__(**kwargs) + self.send_to_subscription_administrator = send_to_subscription_administrator + self.send_to_subscription_co_administrators = send_to_subscription_co_administrators + self.custom_emails = custom_emails + + +class EmailReceiver(_serialization.Model): + """An email receiver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the email receiver. Names must be unique across all receivers within an + action group. Required. + :vartype name: str + :ivar email_address: The email address of this receiver. Required. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + and "Disabled". + :vartype status: str or ~azure.mgmt.monitor.models.ReceiverStatus + """ + + _validation = { + "name": {"required": True}, + "email_address": {"required": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "email_address": {"key": "emailAddress", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: + """ + :keyword name: The name of the email receiver. Names must be unique across all receivers within + an action group. Required. + :paramtype name: str + :keyword email_address: The email address of this receiver. Required. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super().__init__(**kwargs) + self.name = name + self.email_address = email_address + self.use_common_alert_schema = use_common_alert_schema + self.status = None + + +class EnableRequest(_serialization.Model): + """Describes a receiver that should be resubscribed. + + All required parameters must be populated in order to send to server. + + :ivar receiver_name: The name of the receiver to resubscribe. Required. + :vartype receiver_name: str + """ + + _validation = { + "receiver_name": {"required": True}, + } + + _attribute_map = { + "receiver_name": {"key": "receiverName", "type": "str"}, + } + + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: + """ + :keyword receiver_name: The name of the receiver to resubscribe. Required. + :paramtype receiver_name: str + """ + super().__init__(**kwargs) + self.receiver_name = receiver_name + + +class Error(_serialization.Model): + """Error details. + + All required parameters must be populated in order to send to server. + + :ivar code: Error code identifying the specific error. Required. + :vartype code: str + :ivar message: Error message in the caller's locale. + :vartype message: str + """ + + _validation = { + "code": {"required": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: str, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: Error code identifying the specific error. Required. + :paramtype code: str + :keyword message: Error message in the caller's locale. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorContract(_serialization.Model): + """Describes the format of Error response. + + :ivar error: The error details. + :vartype error: ~azure.mgmt.monitor.models.ErrorResponse + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponse"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.monitor.models.ErrorResponse + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorDetail(_serialization.Model): + """Describes details of an error response. + + :ivar code: Unlocalized string which can be used to programmatically identify the error. + :vartype code: str + :ivar message: Describes the error in detail and provides debugging information. + :vartype message: str + :ivar target: The target of the particular error (for example, the name of the property in + error). + :vartype target: str + :ivar additional_info: An array of objects with 'type' and 'info' properties. The schema of + 'info' is service-specific and dependent on the 'type' string. + :vartype additional_info: list[~azure.mgmt.monitor.models.ErrorDetailAdditionalInfoItem] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorDetailAdditionalInfoItem]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + additional_info: Optional[List["_models.ErrorDetailAdditionalInfoItem"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Unlocalized string which can be used to programmatically identify the error. + :paramtype code: str + :keyword message: Describes the error in detail and provides debugging information. + :paramtype message: str + :keyword target: The target of the particular error (for example, the name of the property in + error). + :paramtype target: str + :keyword additional_info: An array of objects with 'type' and 'info' properties. The schema of + 'info' is service-specific and dependent on the 'type' string. + :paramtype additional_info: list[~azure.mgmt.monitor.models.ErrorDetailAdditionalInfoItem] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.additional_info = additional_info + + +class ErrorDetailAdditionalInfoItem(_serialization.Model): + """ErrorDetailAdditionalInfoItem. + + :ivar type: The type of additional information. + :vartype type: str + :ivar info: The additional information specific to the type. + :vartype info: dict[str, any] + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "{object}"}, + } + + def __init__(self, *, type: Optional[str] = None, info: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: + """ + :keyword type: The type of additional information. + :paramtype type: str + :keyword info: The additional information specific to the type. + :paramtype info: dict[str, any] + """ + super().__init__(**kwargs) + self.type = type + self.info = info + + +class ErrorResponse(_serialization.Model): + """Describes the format of Error response. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorResponseAutoGenerated(_serialization.Model): + """Describes the format of Error response. + + :ivar error: + :vartype error: ~azure.mgmt.monitor.models.ErrorResponseError + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseError"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs: Any) -> None: + """ + :keyword error: + :paramtype error: ~azure.mgmt.monitor.models.ErrorResponseError + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseAutoGenerated2(_serialization.Model): + """Describes the format of Error response. + + :ivar error: + :vartype error: ~azure.mgmt.monitor.models.ErrorResponseError + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseError"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs: Any) -> None: + """ + :keyword error: + :paramtype error: ~azure.mgmt.monitor.models.ErrorResponseError + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseCommon(ErrorResponse): + """The resource management error response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.monitor.models.ErrorResponseCommon] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.monitor.models.ErrorAdditionalInfo] + """ + + _validation = { + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponseCommon]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super().__init__(code=code, message=message, **kwargs) + self.details = None + self.additional_info = None + + +class ErrorResponseError(_serialization.Model): + """ErrorResponseError. + + :ivar code: Unlocalized string which can be used to programmatically identify the error. + :vartype code: str + :ivar message: Describes the error in detail and provides debugging information. If + Accept-Language is set in the request, it must be localized to that language. + :vartype message: str + :ivar target: The target of the particular error (for example, the name of the property in + error). + :vartype target: str + :ivar details: An array of additional nested error response info objects, as described by this + contract. + :vartype details: list[~azure.mgmt.monitor.models.ErrorDetail] + :ivar additional_info: An array of objects with 'type' and 'info' properties. The schema of + 'info' is service-specific and dependent on the 'type' string. + :vartype additional_info: list[~azure.mgmt.monitor.models.ErrorResponseErrorAdditionalInfoItem] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorResponseErrorAdditionalInfoItem]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.ErrorDetail"]] = None, + additional_info: Optional[List["_models.ErrorResponseErrorAdditionalInfoItem"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: Unlocalized string which can be used to programmatically identify the error. + :paramtype code: str + :keyword message: Describes the error in detail and provides debugging information. If + Accept-Language is set in the request, it must be localized to that language. + :paramtype message: str + :keyword target: The target of the particular error (for example, the name of the property in + error). + :paramtype target: str + :keyword details: An array of additional nested error response info objects, as described by + this contract. + :paramtype details: list[~azure.mgmt.monitor.models.ErrorDetail] + :keyword additional_info: An array of objects with 'type' and 'info' properties. The schema of + 'info' is service-specific and dependent on the 'type' string. + :paramtype additional_info: + list[~azure.mgmt.monitor.models.ErrorResponseErrorAdditionalInfoItem] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + self.additional_info = additional_info + + +class ErrorResponseErrorAdditionalInfoItem(_serialization.Model): + """ErrorResponseErrorAdditionalInfoItem. + + :ivar type: The type of additional information. + :vartype type: str + :ivar info: The additional information specific to the type. + :vartype info: dict[str, any] + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "{object}"}, + } + + def __init__(self, *, type: Optional[str] = None, info: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: + """ + :keyword type: The type of additional information. + :paramtype type: str + :keyword info: The additional information specific to the type. + :paramtype info: dict[str, any] + """ + super().__init__(**kwargs) + self.type = type + self.info = info + + +class EtwEventConfiguration(_serialization.Model): + """EtwEventConfiguration. + + All required parameters must be populated in order to send to server. + + :ivar name: Required. + :vartype name: str + :ivar id: Required. + :vartype id: int + :ivar filter: + :vartype filter: str + """ + + _validation = { + "name": {"required": True}, + "id": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "int"}, + "filter": {"key": "filter", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: int, # pylint: disable=redefined-builtin + filter: Optional[str] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword name: Required. + :paramtype name: str + :keyword id: Required. + :paramtype id: int + :keyword filter: + :paramtype filter: str + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.filter = filter + + +class EtwProviderConfiguration(_serialization.Model): + """EtwProviderConfiguration. + + All required parameters must be populated in order to send to server. + + :ivar id: Required. + :vartype id: str + :ivar events: Required. + :vartype events: list[~azure.mgmt.monitor.models.EtwEventConfiguration] + """ + + _validation = { + "id": {"required": True}, + "events": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "events": {"key": "events", "type": "[EtwEventConfiguration]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + events: List["_models.EtwEventConfiguration"], + **kwargs: Any + ) -> None: + """ + :keyword id: Required. + :paramtype id: str + :keyword events: Required. + :paramtype events: list[~azure.mgmt.monitor.models.EtwEventConfiguration] + """ + super().__init__(**kwargs) + self.id = id + self.events = events + + +class EventCategoryCollection(_serialization.Model): + """A collection of event categories. Currently possible values are: Administrative, Security, + ServiceHealth, Alert, Recommendation, Policy. + + All required parameters must be populated in order to send to server. + + :ivar value: the list that includes the Azure event categories. Required. + :vartype value: list[~azure.mgmt.monitor.models.LocalizableString] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[LocalizableString]"}, + } + + def __init__(self, *, value: List["_models.LocalizableString"], **kwargs: Any) -> None: + """ + :keyword value: the list that includes the Azure event categories. Required. + :paramtype value: list[~azure.mgmt.monitor.models.LocalizableString] + """ + super().__init__(**kwargs) + self.value = value + + +class EventData(_serialization.Model): + """The Azure event log entries are of type EventData. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar authorization: The sender authorization information. + :vartype authorization: ~azure.mgmt.monitor.models.SenderAuthorization + :ivar claims: key value pairs to identify ARM permissions. + :vartype claims: dict[str, str] + :ivar caller: the email address of the user who has performed the operation, the UPN claim or + SPN claim based on availability. + :vartype caller: str + :ivar description: the description of the event. + :vartype description: str + :ivar id: the Id of this event as required by ARM for RBAC. It contains the EventDataID and a + timestamp information. + :vartype id: str + :ivar event_data_id: the event data Id. This is a unique identifier for an event. + :vartype event_data_id: str + :ivar correlation_id: 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. + :vartype correlation_id: str + :ivar event_name: the event name. This value should not be confused with OperationName. For + practical purposes, OperationName might be more appealing to end users. + :vartype event_name: ~azure.mgmt.monitor.models.LocalizableString + :ivar category: the event category. + :vartype category: ~azure.mgmt.monitor.models.LocalizableString + :ivar http_request: 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). + :vartype http_request: ~azure.mgmt.monitor.models.HttpRequestInfo + :ivar level: the event level. Known values are: "Critical", "Error", "Warning", + "Informational", and "Verbose". + :vartype level: str or ~azure.mgmt.monitor.models.EventLevel + :ivar resource_group_name: the resource group name of the impacted resource. + :vartype resource_group_name: str + :ivar resource_provider_name: the resource provider name of the impacted resource. + :vartype resource_provider_name: ~azure.mgmt.monitor.models.LocalizableString + :ivar resource_id: the resource uri that uniquely identifies the resource that caused this + event. + :vartype resource_id: str + :ivar resource_type: the resource type. + :vartype resource_type: ~azure.mgmt.monitor.models.LocalizableString + :ivar operation_id: It is usually a GUID shared among the events corresponding to single + operation. This value should not be confused with EventName. + :vartype operation_id: str + :ivar operation_name: the operation name. + :vartype operation_name: ~azure.mgmt.monitor.models.LocalizableString + :ivar properties: the set of pairs (usually a Dictionary) that + includes details about the event. + :vartype properties: dict[str, str] + :ivar status: a string describing the status of the operation. Some typical values are: + Started, In progress, Succeeded, Failed, Resolved. + :vartype status: ~azure.mgmt.monitor.models.LocalizableString + :ivar sub_status: 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). + :vartype sub_status: ~azure.mgmt.monitor.models.LocalizableString + :ivar event_timestamp: the timestamp of when the event was generated by the Azure service + processing the request corresponding the event. It in ISO 8601 format. + :vartype event_timestamp: ~datetime.datetime + :ivar submission_timestamp: 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. + :vartype submission_timestamp: ~datetime.datetime + :ivar subscription_id: the Azure subscription Id usually a GUID. + :vartype subscription_id: str + :ivar tenant_id: the Azure tenant Id. + :vartype tenant_id: str + """ + + _validation = { + "authorization": {"readonly": True}, + "claims": {"readonly": True}, + "caller": {"readonly": True}, + "description": {"readonly": True}, + "id": {"readonly": True}, + "event_data_id": {"readonly": True}, + "correlation_id": {"readonly": True}, + "event_name": {"readonly": True}, + "category": {"readonly": True}, + "http_request": {"readonly": True}, + "level": {"readonly": True}, + "resource_group_name": {"readonly": True}, + "resource_provider_name": {"readonly": True}, + "resource_id": {"readonly": True}, + "resource_type": {"readonly": True}, + "operation_id": {"readonly": True}, + "operation_name": {"readonly": True}, + "properties": {"readonly": True}, + "status": {"readonly": True}, + "sub_status": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "submission_timestamp": {"readonly": True}, + "subscription_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "authorization": {"key": "authorization", "type": "SenderAuthorization"}, + "claims": {"key": "claims", "type": "{str}"}, + "caller": {"key": "caller", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "event_data_id": {"key": "eventDataId", "type": "str"}, + "correlation_id": {"key": "correlationId", "type": "str"}, + "event_name": {"key": "eventName", "type": "LocalizableString"}, + "category": {"key": "category", "type": "LocalizableString"}, + "http_request": {"key": "httpRequest", "type": "HttpRequestInfo"}, + "level": {"key": "level", "type": "str"}, + "resource_group_name": {"key": "resourceGroupName", "type": "str"}, + "resource_provider_name": {"key": "resourceProviderName", "type": "LocalizableString"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "LocalizableString"}, + "operation_id": {"key": "operationId", "type": "str"}, + "operation_name": {"key": "operationName", "type": "LocalizableString"}, + "properties": {"key": "properties", "type": "{str}"}, + "status": {"key": "status", "type": "LocalizableString"}, + "sub_status": {"key": "subStatus", "type": "LocalizableString"}, + "event_timestamp": {"key": "eventTimestamp", "type": "iso-8601"}, + "submission_timestamp": {"key": "submissionTimestamp", "type": "iso-8601"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: # pylint: disable=too-many-locals + """ """ + super().__init__(**kwargs) + self.authorization = None + self.claims = None + self.caller = None + self.description = None + self.id = None + self.event_data_id = None + self.correlation_id = None + self.event_name = None + self.category = None + self.http_request = None + self.level = None + self.resource_group_name = None + self.resource_provider_name = None + self.resource_id = None + self.resource_type = None + self.operation_id = None + self.operation_name = None + self.properties = None + self.status = None + self.sub_status = None + self.event_timestamp = None + self.submission_timestamp = None + self.subscription_id = None + self.tenant_id = None + + +class EventDataCollection(_serialization.Model): + """Represents collection of events. + + All required parameters must be populated in order to send to server. + + :ivar value: this list that includes the Azure audit logs. Required. + :vartype value: list[~azure.mgmt.monitor.models.EventData] + :ivar next_link: Provides the link to retrieve the next set of events. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EventData]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.EventData"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: this list that includes the Azure audit logs. Required. + :paramtype value: list[~azure.mgmt.monitor.models.EventData] + :keyword next_link: Provides the link to retrieve the next set of events. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class EventHubReceiver(_serialization.Model): + """An Event hub receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. + :vartype name: str + :ivar event_hub_name_space: The Event Hub namespace. Required. + :vartype event_hub_name_space: str + :ivar event_hub_name: The name of the specific Event Hub queue. Required. + :vartype event_hub_name: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar tenant_id: The tenant Id for the subscription containing this event hub. + :vartype tenant_id: str + :ivar subscription_id: The Id for the subscription containing this event hub. Required. + :vartype subscription_id: str + """ + + _validation = { + "name": {"required": True}, + "event_hub_name_space": {"required": True}, + "event_hub_name": {"required": True}, + "subscription_id": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, + "event_hub_name": {"key": "eventHubName", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + event_hub_name_space: str, + event_hub_name: str, + subscription_id: str, + use_common_alert_schema: bool = False, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the Event hub receiver. Names must be unique across all receivers + within an action group. Required. + :paramtype name: str + :keyword event_hub_name_space: The Event Hub namespace. Required. + :paramtype event_hub_name_space: str + :keyword event_hub_name: The name of the specific Event Hub queue. Required. + :paramtype event_hub_name: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword tenant_id: The tenant Id for the subscription containing this event hub. + :paramtype tenant_id: str + :keyword subscription_id: The Id for the subscription containing this event hub. Required. + :paramtype subscription_id: str + """ + super().__init__(**kwargs) + self.name = name + self.event_hub_name_space = event_hub_name_space + self.event_hub_name = event_hub_name + self.use_common_alert_schema = use_common_alert_schema + self.tenant_id = tenant_id + self.subscription_id = subscription_id + + +class EventLogConfiguration(_serialization.Model): + """EventLogConfiguration. + + All required parameters must be populated in order to send to server. + + :ivar log_name: Required. + :vartype log_name: str + :ivar filter: + :vartype filter: str + """ + + _validation = { + "log_name": {"required": True}, + } + + _attribute_map = { + "log_name": {"key": "logName", "type": "str"}, + "filter": {"key": "filter", "type": "str"}, + } + + def __init__( + self, *, log_name: str, filter: Optional[str] = None, **kwargs: Any # pylint: disable=redefined-builtin + ) -> None: + """ + :keyword log_name: Required. + :paramtype log_name: str + :keyword filter: + :paramtype filter: str + """ + super().__init__(**kwargs) + self.log_name = log_name + self.filter = filter + + +class GuestDiagnosticSettingsAssociationList(_serialization.Model): + """A list of guest diagnostic settings association. + + :ivar value: The list of guest diagnostic settings association. + :vartype value: list[~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GuestDiagnosticSettingsAssociationResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GuestDiagnosticSettingsAssociationResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of guest diagnostic settings association. + :paramtype value: list[~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GuestDiagnosticSettingsAssociationResource(Resource): # pylint: disable=name-too-long + """Virtual machine guest diagnostic settings resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. Required. + :vartype guest_diagnostic_settings_name: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "guest_diagnostic_settings_name": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "guest_diagnostic_settings_name": {"key": "properties.guestDiagnosticSettingsName", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + guest_diagnostic_settings_name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. Required. + :paramtype guest_diagnostic_settings_name: str + """ + super().__init__(location=location, tags=tags, **kwargs) + self.guest_diagnostic_settings_name = guest_diagnostic_settings_name + + +class GuestDiagnosticSettingsAssociationResourcePatch(_serialization.Model): # pylint: disable=name-too-long + """Guest diagnostic setting resource for patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. + :vartype guest_diagnostic_settings_name: str + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "guest_diagnostic_settings_name": {"key": "properties.guestDiagnosticSettingsName", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + guest_diagnostic_settings_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. + :paramtype guest_diagnostic_settings_name: str + """ + super().__init__(**kwargs) + self.tags = tags + self.guest_diagnostic_settings_name = guest_diagnostic_settings_name + + +class GuestDiagnosticSettingsList(_serialization.Model): + """A list of guest diagnostic settings. + + :ivar value: The list of guest diagnostic settings. + :vartype value: list[~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GuestDiagnosticSettingsResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GuestDiagnosticSettingsResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of guest diagnostic settings. + :paramtype value: list[~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GuestDiagnosticSettingsPatchResource(_serialization.Model): + """An diagnostic settings object for the body of patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar os_type: Operating system type for the configuration. Known values are: "Windows" and + "Linux". + :vartype os_type: str or ~azure.mgmt.monitor.models.GuestDiagnosticSettingsOsType + :ivar data_sources: the array of data source object which are configured to collect and send + data. + :vartype data_sources: list[~azure.mgmt.monitor.models.DataSource] + :ivar proxy_setting: + :vartype proxy_setting: str + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "data_sources": {"key": "properties.dataSources", "type": "[DataSource]"}, + "proxy_setting": {"key": "properties.proxySetting", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, + data_sources: Optional[List["_models.DataSource"]] = None, + proxy_setting: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword os_type: Operating system type for the configuration. Known values are: "Windows" and + "Linux". + :paramtype os_type: str or ~azure.mgmt.monitor.models.GuestDiagnosticSettingsOsType + :keyword data_sources: the array of data source object which are configured to collect and send + data. + :paramtype data_sources: list[~azure.mgmt.monitor.models.DataSource] + :keyword proxy_setting: + :paramtype proxy_setting: str + """ + super().__init__(**kwargs) + self.tags = tags + self.os_type = os_type + self.data_sources = data_sources + self.proxy_setting = proxy_setting + + +class GuestDiagnosticSettingsResource(Resource): + """Virtual machine guest diagnostics settings resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar os_type: Operating system type for the configuration. Known values are: "Windows" and + "Linux". + :vartype os_type: str or ~azure.mgmt.monitor.models.GuestDiagnosticSettingsOsType + :ivar data_sources: the array of data source object which are configured to collect and send + data. + :vartype data_sources: list[~azure.mgmt.monitor.models.DataSource] + :ivar proxy_setting: + :vartype proxy_setting: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "data_sources": {"key": "properties.dataSources", "type": "[DataSource]"}, + "proxy_setting": {"key": "properties.proxySetting", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, + data_sources: Optional[List["_models.DataSource"]] = None, + proxy_setting: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword os_type: Operating system type for the configuration. Known values are: "Windows" and + "Linux". + :paramtype os_type: str or ~azure.mgmt.monitor.models.GuestDiagnosticSettingsOsType + :keyword data_sources: the array of data source object which are configured to collect and send + data. + :paramtype data_sources: list[~azure.mgmt.monitor.models.DataSource] + :keyword proxy_setting: + :paramtype proxy_setting: str + """ + super().__init__(location=location, tags=tags, **kwargs) + self.os_type = os_type + self.data_sources = data_sources + self.proxy_setting = proxy_setting + + +class HttpRequestInfo(_serialization.Model): + """The Http request info. + + :ivar client_request_id: the client request id. + :vartype client_request_id: str + :ivar client_ip_address: the client Ip Address. + :vartype client_ip_address: str + :ivar method: the Http request method. + :vartype method: str + :ivar uri: the Uri. + :vartype uri: str + """ + + _attribute_map = { + "client_request_id": {"key": "clientRequestId", "type": "str"}, + "client_ip_address": {"key": "clientIpAddress", "type": "str"}, + "method": {"key": "method", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + } + + def __init__( + self, + *, + client_request_id: Optional[str] = None, + client_ip_address: Optional[str] = None, + method: Optional[str] = None, + uri: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword client_request_id: the client request id. + :paramtype client_request_id: str + :keyword client_ip_address: the client Ip Address. + :paramtype client_ip_address: str + :keyword method: the Http request method. + :paramtype method: str + :keyword uri: the Uri. + :paramtype uri: str + """ + super().__init__(**kwargs) + self.client_request_id = client_request_id + self.client_ip_address = client_ip_address + self.method = method + self.uri = uri + + +class Incident(_serialization.Model): + """An alert incident indicates the activation status of an alert rule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Incident name. + :vartype name: str + :ivar rule_name: Rule name that is associated with the incident. + :vartype rule_name: str + :ivar is_active: A boolean to indicate whether the incident is active or resolved. + :vartype is_active: bool + :ivar activated_time: The time at which the incident was activated in ISO8601 format. + :vartype activated_time: ~datetime.datetime + :ivar resolved_time: The time at which the incident was resolved in ISO8601 format. If null, it + means the incident is still active. + :vartype resolved_time: ~datetime.datetime + """ + + _validation = { + "name": {"readonly": True}, + "rule_name": {"readonly": True}, + "is_active": {"readonly": True}, + "activated_time": {"readonly": True}, + "resolved_time": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "rule_name": {"key": "ruleName", "type": "str"}, + "is_active": {"key": "isActive", "type": "bool"}, + "activated_time": {"key": "activatedTime", "type": "iso-8601"}, + "resolved_time": {"key": "resolvedTime", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.rule_name = None + self.is_active = None + self.activated_time = None + self.resolved_time = None + + +class IncidentListResult(_serialization.Model): + """The List incidents operation response. + + :ivar value: the incident collection. + :vartype value: list[~azure.mgmt.monitor.models.Incident] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Incident]"}, + } + + def __init__(self, *, value: Optional[List["_models.Incident"]] = None, **kwargs: Any) -> None: + """ + :keyword value: the incident collection. + :paramtype value: list[~azure.mgmt.monitor.models.Incident] + """ + super().__init__(**kwargs) + self.value = value + + +class ItsmReceiver(_serialization.Model): + """An Itsm receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an + action group. Required. + :vartype name: str + :ivar workspace_id: OMS LA instance identifier. Required. + :vartype workspace_id: str + :ivar connection_id: Unique identification of ITSM connection among multiple defined in above + workspace. Required. + :vartype connection_id: str + :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. + :vartype ticket_configuration: str + :ivar region: Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. # pylint: disable=line-too-long + Required. + :vartype region: str + """ + + _validation = { + "name": {"required": True}, + "workspace_id": {"required": True}, + "connection_id": {"required": True}, + "ticket_configuration": {"required": True}, + "region": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "connection_id": {"key": "connectionId", "type": "str"}, + "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, + "region": {"key": "region", "type": "str"}, + } + + def __init__( + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: + """ + :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within + an action group. Required. + :paramtype name: str + :keyword workspace_id: OMS LA instance identifier. Required. + :paramtype workspace_id: str + :keyword connection_id: Unique identification of ITSM connection among multiple defined in + above workspace. Required. + :paramtype connection_id: str + :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. Required. + :paramtype ticket_configuration: str + :keyword region: Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. # pylint: disable=line-too-long + Required. + :paramtype region: str + """ + super().__init__(**kwargs) + self.name = name + self.workspace_id = workspace_id + self.connection_id = connection_id + self.ticket_configuration = ticket_configuration + self.region = region + + +class LocalizableString(_serialization.Model): + """The localizable string class. + + All required parameters must be populated in order to send to server. + + :ivar value: the invariant value. Required. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: the invariant value. Required. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ + super().__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class LocalizableStringAutoGenerated(_serialization.Model): + """The localizable string class. + + All required parameters must be populated in order to send to server. + + :ivar value: The invariant value. Required. + :vartype value: str + :ivar localized_value: The display name. + :vartype localized_value: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The invariant value. Required. + :paramtype value: str + :keyword localized_value: The display name. + :paramtype localized_value: str + """ + super().__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class LogicAppReceiver(_serialization.Model): + """A logic app receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. + :vartype name: str + :ivar resource_id: The azure resource id of the logic app receiver. Required. + :vartype resource_id: str + :ivar callback_url: The callback url where http request sent to. Required. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + "name": {"required": True}, + "resource_id": {"required": True}, + "callback_url": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "callback_url": {"key": "callbackUrl", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + } + + def __init__( + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any + ) -> None: + """ + :keyword name: The name of the logic app receiver. Names must be unique across all receivers + within an action group. Required. + :paramtype name: str + :keyword resource_id: The azure resource id of the logic app receiver. Required. + :paramtype resource_id: str + :keyword callback_url: The callback url where http request sent to. Required. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super().__init__(**kwargs) + self.name = name + self.resource_id = resource_id + self.callback_url = callback_url + self.use_common_alert_schema = use_common_alert_schema + + +class LogMetricTrigger(_serialization.Model): + """A log metrics trigger descriptor. + + :ivar threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or + 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", + and "Equal". + :vartype threshold_operator: str or ~azure.mgmt.monitor.models.ConditionalOperator + :ivar threshold: The threshold of the metric trigger. + :vartype threshold: float + :ivar metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: + "Consecutive" and "Total". + :vartype metric_trigger_type: str or ~azure.mgmt.monitor.models.MetricTriggerType + :ivar metric_column: Evaluation of metric on a particular column. + :vartype metric_column: str + """ + + _attribute_map = { + "threshold_operator": {"key": "thresholdOperator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "metric_trigger_type": {"key": "metricTriggerType", "type": "str"}, + "metric_column": {"key": "metricColumn", "type": "str"}, + } + + def __init__( + self, + *, + threshold_operator: Union[str, "_models.ConditionalOperator"] = "GreaterThanOrEqual", + threshold: Optional[float] = None, + metric_trigger_type: Union[str, "_models.MetricTriggerType"] = "Consecutive", + metric_column: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or + 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", + and "Equal". + :paramtype threshold_operator: str or ~azure.mgmt.monitor.models.ConditionalOperator + :keyword threshold: The threshold of the metric trigger. + :paramtype threshold: float + :keyword metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: + "Consecutive" and "Total". + :paramtype metric_trigger_type: str or ~azure.mgmt.monitor.models.MetricTriggerType + :keyword metric_column: Evaluation of metric on a particular column. + :paramtype metric_column: str + """ + super().__init__(**kwargs) + self.threshold_operator = threshold_operator + self.threshold = threshold + self.metric_trigger_type = metric_trigger_type + self.metric_column = metric_column + + +class LogProfileCollection(_serialization.Model): + """Represents a collection of log profiles. + + All required parameters must be populated in order to send to server. + + :ivar value: the values of the log profiles. Required. + :vartype value: list[~azure.mgmt.monitor.models.LogProfileResource] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[LogProfileResource]"}, + } + + def __init__(self, *, value: List["_models.LogProfileResource"], **kwargs: Any) -> None: + """ + :keyword value: the values of the log profiles. Required. + :paramtype value: list[~azure.mgmt.monitor.models.LogProfileResource] + """ + super().__init__(**kwargs) + self.value = value + + +class LogProfileResource(Resource): + """The log profile resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :vartype storage_account_id: str + :ivar service_bus_rule_id: 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}'. + :vartype service_bus_rule_id: str + :ivar locations: 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. Required. + :vartype locations: list[str] + :ivar categories: the categories of the logs. These categories are created as is convenient to + the user. Some values are: 'Write', 'Delete', and/or 'Action.'. Required. + :vartype categories: list[str] + :ivar retention_policy: the retention policy for the events in the log. Required. + :vartype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "locations": {"required": True}, + "categories": {"required": True}, + "retention_policy": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "locations": {"key": "properties.locations", "type": "[str]"}, + "categories": {"key": "properties.categories", "type": "[str]"}, + "retention_policy": {"key": "properties.retentionPolicy", "type": "RetentionPolicy"}, + } + + def __init__( + self, + *, + location: str, + locations: List[str], + categories: List[str], + retention_policy: "_models.RetentionPolicy", + tags: Optional[Dict[str, str]] = None, + storage_account_id: Optional[str] = None, + service_bus_rule_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: 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}'. + :paramtype service_bus_rule_id: str + :keyword locations: 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. Required. + :paramtype locations: list[str] + :keyword categories: the categories of the logs. These categories are created as is convenient + to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. Required. + :paramtype categories: list[str] + :keyword retention_policy: the retention policy for the events in the log. Required. + :paramtype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + super().__init__(location=location, tags=tags, **kwargs) + self.storage_account_id = storage_account_id + self.service_bus_rule_id = service_bus_rule_id + self.locations = locations + self.categories = categories + self.retention_policy = retention_policy + + +class LogProfileResourcePatch(_serialization.Model): + """The log profile resource for patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :vartype storage_account_id: str + :ivar service_bus_rule_id: 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}'. + :vartype service_bus_rule_id: str + :ivar locations: 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. + :vartype locations: list[str] + :ivar categories: the categories of the logs. These categories are created as is convenient to + the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :vartype categories: list[str] + :ivar retention_policy: the retention policy for the events in the log. + :vartype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "locations": {"key": "properties.locations", "type": "[str]"}, + "categories": {"key": "properties.categories", "type": "[str]"}, + "retention_policy": {"key": "properties.retentionPolicy", "type": "RetentionPolicy"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + storage_account_id: Optional[str] = None, + service_bus_rule_id: Optional[str] = None, + locations: Optional[List[str]] = None, + categories: Optional[List[str]] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: 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}'. + :paramtype service_bus_rule_id: str + :keyword locations: 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. + :paramtype locations: list[str] + :keyword categories: the categories of the logs. These categories are created as is convenient + to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :paramtype categories: list[str] + :keyword retention_policy: the retention policy for the events in the log. + :paramtype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + super().__init__(**kwargs) + self.tags = tags + self.storage_account_id = storage_account_id + self.service_bus_rule_id = service_bus_rule_id + self.locations = locations + self.categories = categories + self.retention_policy = retention_policy + + +class ResourceAutoGenerated3(_serialization.Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar etag: The etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal etag convention. Entity tags are used for + comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in + the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range + (section 14.27) header fields. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.kind = None + self.etag = None + + +class LogSearchRuleResource(ResourceAutoGenerated3): + """The Log Search Rule resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar etag: The etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal etag convention. Entity tags are used for + comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in + the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range + (section 14.27) header fields. + :vartype etag: str + :ivar created_with_api_version: The api-version used when creating this alert rule. + :vartype created_with_api_version: str + :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. + :vartype is_legacy_log_analytics_rule: bool + :ivar description: The description of the Log Search rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved + or not. The default is false. + :vartype auto_mitigate: bool + :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be + true or false. Known values are: "true" and "false". + :vartype enabled: str or ~azure.mgmt.monitor.models.Enabled + :ivar last_updated_time: Last time the rule was updated in IS08601 format. + :vartype last_updated_time: ~datetime.datetime + :ivar provisioning_state: Provisioning state of the scheduled query rule. Known values are: + "Succeeded", "Deploying", "Canceled", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.monitor.models.ProvisioningState + :ivar source: Data Source against which rule will Query Data. Required. + :vartype source: ~azure.mgmt.monitor.models.Source + :ivar schedule: Schedule (Frequency, Time Window) for rule. Required for action type - + AlertingAction. + :vartype schedule: ~azure.mgmt.monitor.models.Schedule + :ivar action: Action needs to be taken on rule execution. Required. + :vartype action: ~azure.mgmt.monitor.models.Action + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "etag": {"readonly": True}, + "created_with_api_version": {"readonly": True}, + "is_legacy_log_analytics_rule": {"readonly": True}, + "last_updated_time": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "source": {"required": True}, + "action": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, + "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "enabled": {"key": "properties.enabled", "type": "str"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "source": {"key": "properties.source", "type": "Source"}, + "schedule": {"key": "properties.schedule", "type": "Schedule"}, + "action": {"key": "properties.action", "type": "Action"}, + } + + def __init__( + self, + *, + location: str, + source: "_models.Source", + action: "_models.Action", + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + display_name: Optional[str] = None, + auto_mitigate: bool = False, + enabled: Optional[Union[str, "_models.Enabled"]] = None, + schedule: Optional["_models.Schedule"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of the Log Search rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword auto_mitigate: The flag that indicates whether the alert should be automatically + resolved or not. The default is false. + :paramtype auto_mitigate: bool + :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should + be true or false. Known values are: "true" and "false". + :paramtype enabled: str or ~azure.mgmt.monitor.models.Enabled + :keyword source: Data Source against which rule will Query Data. Required. + :paramtype source: ~azure.mgmt.monitor.models.Source + :keyword schedule: Schedule (Frequency, Time Window) for rule. Required for action type - + AlertingAction. + :paramtype schedule: ~azure.mgmt.monitor.models.Schedule + :keyword action: Action needs to be taken on rule execution. Required. + :paramtype action: ~azure.mgmt.monitor.models.Action + """ + super().__init__(location=location, tags=tags, **kwargs) + self.created_with_api_version = None + self.is_legacy_log_analytics_rule = None + self.description = description + self.display_name = display_name + self.auto_mitigate = auto_mitigate + self.enabled = enabled + self.last_updated_time = None + self.provisioning_state = None + self.source = source + self.schedule = schedule + self.action = action + + +class LogSearchRuleResourceCollection(_serialization.Model): + """Represents a collection of Log Search rule resources. + + :ivar value: The values for the Log Search Rule resources. + :vartype value: list[~azure.mgmt.monitor.models.LogSearchRuleResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[LogSearchRuleResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.LogSearchRuleResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The values for the Log Search Rule resources. + :paramtype value: list[~azure.mgmt.monitor.models.LogSearchRuleResource] + """ + super().__init__(**kwargs) + self.value = value + + +class LogSearchRuleResourcePatch(_serialization.Model): + """The log search rule resource for patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be + true or false. Known values are: "true" and "false". + :vartype enabled: str or ~azure.mgmt.monitor.models.Enabled + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "enabled": {"key": "properties.enabled", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + enabled: Optional[Union[str, "_models.Enabled"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should + be true or false. Known values are: "true" and "false". + :paramtype enabled: str or ~azure.mgmt.monitor.models.Enabled + """ + super().__init__(**kwargs) + self.tags = tags + self.enabled = enabled + + +class LogSettings(_serialization.Model): + """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. + + All required parameters must be populated in order to send to server. + + :ivar category: 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. + :vartype category: str + :ivar category_group: Name of a Diagnostic Log category group 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. + :vartype category_group: str + :ivar enabled: a value indicating whether this log is enabled. Required. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "category": {"key": "category", "type": "str"}, + "category_group": {"key": "categoryGroup", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + } + + def __init__( + self, + *, + enabled: bool, + category: Optional[str] = None, + category_group: Optional[str] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword category: 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. + :paramtype category: str + :keyword category_group: Name of a Diagnostic Log category group 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. + :paramtype category_group: str + :keyword enabled: a value indicating whether this log is enabled. Required. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + super().__init__(**kwargs) + self.category = category + self.category_group = category_group + self.enabled = enabled + self.retention_policy = retention_policy + + +class LogSettingsAutoGenerated(_serialization.Model): + """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. + + All required parameters must be populated in order to send to server. + + :ivar category: 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. + :vartype category: str + :ivar enabled: a value indicating whether this log is enabled. Required. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + } + + def __init__( + self, + *, + enabled: bool, + category: Optional[str] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword category: 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. + :paramtype category: str + :keyword enabled: a value indicating whether this log is enabled. Required. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + super().__init__(**kwargs) + self.category = category + self.enabled = enabled + self.retention_policy = retention_policy + + +class LogToMetricAction(Action): + """Specify action need to be taken when rule type is converting log to metric. + + All required parameters must be populated in order to send to server. + + :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. + Required. + :vartype odata_type: str + :ivar criteria: Criteria of Metric. Required. + :vartype criteria: list[~azure.mgmt.monitor.models.Criteria] + """ + + _validation = { + "odata_type": {"required": True}, + "criteria": {"required": True}, + } + + _attribute_map = { + "odata_type": {"key": "odata\\.type", "type": "str"}, + "criteria": {"key": "criteria", "type": "[Criteria]"}, + } + + def __init__(self, *, criteria: List["_models.Criteria"], **kwargs: Any) -> None: + """ + :keyword criteria: Criteria of Metric. Required. + :paramtype criteria: list[~azure.mgmt.monitor.models.Criteria] + """ + super().__init__(**kwargs) + self.odata_type: str = ( + "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction" + ) + self.criteria = criteria + + +class MetadataValue(_serialization.Model): + """Represents a metric metadata value. + + :ivar name: The name of the metadata. + :vartype name: ~azure.mgmt.monitor.models.LocalizableStringAutoGenerated + :ivar value: The value of the metadata. + :vartype value: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "LocalizableStringAutoGenerated"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional["_models.LocalizableStringAutoGenerated"] = None, + value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the metadata. + :paramtype name: ~azure.mgmt.monitor.models.LocalizableStringAutoGenerated + :keyword value: The value of the metadata. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class Metric(_serialization.Model): + """The result data of a query. + + All required parameters must be populated in order to send to server. + + :ivar id: The metric Id. Required. + :vartype id: str + :ivar type: The resource type of the metric resource. Required. + :vartype type: str + :ivar name: The name and the display name of the metric, i.e. it is localizable string. + Required. + :vartype name: ~azure.mgmt.monitor.models.LocalizableStringAutoGenerated + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar error_code: 'Success' or the error details on query failures for this metric. + :vartype error_code: str + :ivar error_message: Error message encountered querying this specific metric. + :vartype error_message: str + :ivar unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". + :vartype unit: str or ~azure.mgmt.monitor.models.MetricUnit + :ivar timeseries: The time series returned when a data query is performed. Required. + :vartype timeseries: list[~azure.mgmt.monitor.models.TimeSeriesElement] + """ + + _validation = { + "id": {"required": True}, + "type": {"required": True}, + "name": {"required": True}, + "unit": {"required": True}, + "timeseries": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "LocalizableStringAutoGenerated"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "timeseries": {"key": "timeseries", "type": "[TimeSeriesElement]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + type: str, + name: "_models.LocalizableStringAutoGenerated", + unit: Union[str, "_models.MetricUnit"], + timeseries: List["_models.TimeSeriesElement"], + display_description: Optional[str] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The metric Id. Required. + :paramtype id: str + :keyword type: The resource type of the metric resource. Required. + :paramtype type: str + :keyword name: The name and the display name of the metric, i.e. it is localizable string. + Required. + :paramtype name: ~azure.mgmt.monitor.models.LocalizableStringAutoGenerated + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword error_code: 'Success' or the error details on query failures for this metric. + :paramtype error_code: str + :keyword error_message: Error message encountered querying this specific metric. + :paramtype error_message: str + :keyword unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". + :paramtype unit: str or ~azure.mgmt.monitor.models.MetricUnit + :keyword timeseries: The time series returned when a data query is performed. Required. + :paramtype timeseries: list[~azure.mgmt.monitor.models.TimeSeriesElement] + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.name = name + self.display_description = display_description + self.error_code = error_code + self.error_message = error_message + self.unit = unit + self.timeseries = timeseries + + +class MetricAlertAction(_serialization.Model): + """An alert action. + + :ivar action_group_id: the id of the action group to use. + :vartype action_group_id: str + :ivar web_hook_properties: This field allows specifying custom properties, which would be + appended to the alert payload sent as input to the webhook. + :vartype web_hook_properties: dict[str, str] + """ + + _attribute_map = { + "action_group_id": {"key": "actionGroupId", "type": "str"}, + "web_hook_properties": {"key": "webHookProperties", "type": "{str}"}, + } + + def __init__( + self, + *, + action_group_id: Optional[str] = None, + web_hook_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword action_group_id: the id of the action group to use. + :paramtype action_group_id: str + :keyword web_hook_properties: This field allows specifying custom properties, which would be + appended to the alert payload sent as input to the webhook. + :paramtype web_hook_properties: dict[str, str] + """ + super().__init__(**kwargs) + self.action_group_id = action_group_id + self.web_hook_properties = web_hook_properties + + +class MetricAlertCriteria(_serialization.Model): + """The rule criteria that defines the conditions of the alert rule. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + MetricAlertMultipleResourceMultipleMetricCriteria, + MetricAlertSingleResourceMultipleMetricCriteria, WebtestLocationAvailabilityCriteria + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". + :vartype odata_type: str or ~azure.mgmt.monitor.models.Odatatype + """ + + _validation = { + "odata_type": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + } + + _subtype_map = { + "odata_type": { + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria": "MetricAlertMultipleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria": "MetricAlertSingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria": "WebtestLocationAvailabilityCriteria", + } + } + + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + """ + super().__init__(**kwargs) + self.additional_properties = additional_properties + self.odata_type: Optional[str] = None + + +class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): # pylint: disable=name-too-long + """Specifies the metric alert criteria for multiple resource that has multiple metric criteria. + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". + :vartype odata_type: str or ~azure.mgmt.monitor.models.Odatatype + :ivar all_of: the list of multiple metric criteria for this 'all of' operation. + :vartype all_of: list[~azure.mgmt.monitor.models.MultiMetricCriteria] + """ + + _validation = { + "odata_type": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "all_of": {"key": "allOf", "type": "[MultiMetricCriteria]"}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, JSON]] = None, + all_of: Optional[List["_models.MultiMetricCriteria"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + :keyword all_of: the list of multiple metric criteria for this 'all of' operation. + :paramtype all_of: list[~azure.mgmt.monitor.models.MultiMetricCriteria] + """ + super().__init__(additional_properties=additional_properties, **kwargs) + self.odata_type: str = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + self.all_of = all_of + + +class MetricAlertResource(Resource): + """The metric alert resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar description: the description of the metric alert that will be included in the alert + email. + :vartype description: str + :ivar severity: Alert severity {0, 1, 2, 3, 4}. Required. + :vartype severity: int + :ivar enabled: the flag that indicates whether the metric alert is enabled. Required. + :vartype enabled: bool + :ivar scopes: the list of resource id's that this metric alert is scoped to. Required. + :vartype scopes: list[str] + :ivar evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. Required. + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. Required. + :vartype window_size: ~datetime.timedelta + :ivar target_resource_type: 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. + :vartype target_resource_type: str + :ivar target_resource_region: 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. + :vartype target_resource_region: str + :ivar criteria: defines the specific alert criteria information. Required. + :vartype criteria: ~azure.mgmt.monitor.models.MetricAlertCriteria + :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. + The default is true. + :vartype auto_mitigate: bool + :ivar actions: the array of actions that are performed when the alert rule becomes active, and + when an alert condition is resolved. + :vartype actions: list[~azure.mgmt.monitor.models.MetricAlertAction] + :ivar last_updated_time: Last time the rule was updated in ISO8601 format. + :vartype last_updated_time: ~datetime.datetime + :ivar is_migrated: the value indicating whether this alert rule is migrated. + :vartype is_migrated: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "severity": {"required": True}, + "enabled": {"required": True}, + "scopes": {"required": True}, + "evaluation_frequency": {"required": True}, + "window_size": {"required": True}, + "criteria": {"required": True}, + "last_updated_time": {"readonly": True}, + "is_migrated": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "severity": {"key": "properties.severity", "type": "int"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "target_resource_type": {"key": "properties.targetResourceType", "type": "str"}, + "target_resource_region": {"key": "properties.targetResourceRegion", "type": "str"}, + "criteria": {"key": "properties.criteria", "type": "MetricAlertCriteria"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "actions": {"key": "properties.actions", "type": "[MetricAlertAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "is_migrated": {"key": "properties.isMigrated", "type": "bool"}, + } + + def __init__( + self, + *, + location: str, + severity: int, + enabled: bool, + scopes: List[str], + evaluation_frequency: datetime.timedelta, + window_size: datetime.timedelta, + criteria: "_models.MetricAlertCriteria", + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + target_resource_type: Optional[str] = None, + target_resource_region: Optional[str] = None, + auto_mitigate: Optional[bool] = None, + actions: Optional[List["_models.MetricAlertAction"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: the description of the metric alert that will be included in the alert + email. + :paramtype description: str + :keyword severity: Alert severity {0, 1, 2, 3, 4}. Required. + :paramtype severity: int + :keyword enabled: the flag that indicates whether the metric alert is enabled. Required. + :paramtype enabled: bool + :keyword scopes: the list of resource id's that this metric alert is scoped to. Required. + :paramtype scopes: list[str] + :keyword evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. Required. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. Required. + :paramtype window_size: ~datetime.timedelta + :keyword target_resource_type: 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. + :paramtype target_resource_type: str + :keyword target_resource_region: 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. + :paramtype target_resource_region: str + :keyword criteria: defines the specific alert criteria information. Required. + :paramtype criteria: ~azure.mgmt.monitor.models.MetricAlertCriteria + :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or + not. The default is true. + :paramtype auto_mitigate: bool + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~azure.mgmt.monitor.models.MetricAlertAction] + """ + super().__init__(location=location, tags=tags, **kwargs) + self.description = description + self.severity = severity + self.enabled = enabled + self.scopes = scopes + self.evaluation_frequency = evaluation_frequency + self.window_size = window_size + self.target_resource_type = target_resource_type + self.target_resource_region = target_resource_region + self.criteria = criteria + self.auto_mitigate = auto_mitigate + self.actions = actions + self.last_updated_time = None + self.is_migrated = None + + +class MetricAlertResourceCollection(_serialization.Model): + """Represents a collection of alert rule resources. + + :ivar value: the values for the alert rule resources. + :vartype value: list[~azure.mgmt.monitor.models.MetricAlertResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MetricAlertResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.MetricAlertResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~azure.mgmt.monitor.models.MetricAlertResource] + """ + super().__init__(**kwargs) + self.value = value + + +class MetricAlertResourcePatch(_serialization.Model): + """The metric alert resource for patch operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar description: the description of the metric alert that will be included in the alert + email. + :vartype description: str + :ivar severity: Alert severity {0, 1, 2, 3, 4}. + :vartype severity: int + :ivar enabled: the flag that indicates whether the metric alert is enabled. + :vartype enabled: bool + :ivar scopes: the list of resource id's that this metric alert is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. + :vartype window_size: ~datetime.timedelta + :ivar target_resource_type: the resource type of the target resource(s) on which the alert is + created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :vartype target_resource_type: str + :ivar target_resource_region: the region of the target resource(s) on which the alert is + created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :vartype target_resource_region: str + :ivar criteria: defines the specific alert criteria information. + :vartype criteria: ~azure.mgmt.monitor.models.MetricAlertCriteria + :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. + The default is true. + :vartype auto_mitigate: bool + :ivar actions: the array of actions that are performed when the alert rule becomes active, and + when an alert condition is resolved. + :vartype actions: list[~azure.mgmt.monitor.models.MetricAlertAction] + :ivar last_updated_time: Last time the rule was updated in ISO8601 format. + :vartype last_updated_time: ~datetime.datetime + :ivar is_migrated: the value indicating whether this alert rule is migrated. + :vartype is_migrated: bool + """ + + _validation = { + "last_updated_time": {"readonly": True}, + "is_migrated": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "description": {"key": "properties.description", "type": "str"}, + "severity": {"key": "properties.severity", "type": "int"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "target_resource_type": {"key": "properties.targetResourceType", "type": "str"}, + "target_resource_region": {"key": "properties.targetResourceRegion", "type": "str"}, + "criteria": {"key": "properties.criteria", "type": "MetricAlertCriteria"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "actions": {"key": "properties.actions", "type": "[MetricAlertAction]"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "is_migrated": {"key": "properties.isMigrated", "type": "bool"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + severity: Optional[int] = None, + enabled: Optional[bool] = None, + scopes: Optional[List[str]] = None, + evaluation_frequency: Optional[datetime.timedelta] = None, + window_size: Optional[datetime.timedelta] = None, + target_resource_type: Optional[str] = None, + target_resource_region: Optional[str] = None, + criteria: Optional["_models.MetricAlertCriteria"] = None, + auto_mitigate: Optional[bool] = None, + actions: Optional[List["_models.MetricAlertAction"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: the description of the metric alert that will be included in the alert + email. + :paramtype description: str + :keyword severity: Alert severity {0, 1, 2, 3, 4}. + :paramtype severity: int + :keyword enabled: the flag that indicates whether the metric alert is enabled. + :paramtype enabled: bool + :keyword scopes: the list of resource id's that this metric alert is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. + :paramtype window_size: ~datetime.timedelta + :keyword target_resource_type: the resource type of the target resource(s) on which the alert + is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :paramtype target_resource_type: str + :keyword target_resource_region: the region of the target resource(s) on which the alert is + created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :paramtype target_resource_region: str + :keyword criteria: defines the specific alert criteria information. + :paramtype criteria: ~azure.mgmt.monitor.models.MetricAlertCriteria + :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or + not. The default is true. + :paramtype auto_mitigate: bool + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~azure.mgmt.monitor.models.MetricAlertAction] + """ + super().__init__(**kwargs) + self.tags = tags + self.description = description + self.severity = severity + self.enabled = enabled + self.scopes = scopes + self.evaluation_frequency = evaluation_frequency + self.window_size = window_size + self.target_resource_type = target_resource_type + self.target_resource_region = target_resource_region + self.criteria = criteria + self.auto_mitigate = auto_mitigate + self.actions = actions + self.last_updated_time = None + self.is_migrated = None + + +class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): # pylint: disable=name-too-long + """Specifies the metric alert criteria for a single resource that has multiple metric criteria. + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". + :vartype odata_type: str or ~azure.mgmt.monitor.models.Odatatype + :ivar all_of: The list of metric criteria for this 'all of' operation. + :vartype all_of: list[~azure.mgmt.monitor.models.MetricCriteria] + """ + + _validation = { + "odata_type": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "all_of": {"key": "allOf", "type": "[MetricCriteria]"}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, JSON]] = None, + all_of: Optional[List["_models.MetricCriteria"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + :keyword all_of: The list of metric criteria for this 'all of' operation. + :paramtype all_of: list[~azure.mgmt.monitor.models.MetricCriteria] + """ + super().__init__(additional_properties=additional_properties, **kwargs) + self.odata_type: str = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" + self.all_of = all_of + + +class MetricAlertStatus(_serialization.Model): + """An alert status. + + :ivar name: The status name. + :vartype name: str + :ivar id: The alert rule arm id. + :vartype id: str + :ivar type: The extended resource type name. + :vartype type: str + :ivar properties: The alert status properties of the metric alert status. + :vartype properties: ~azure.mgmt.monitor.models.MetricAlertStatusProperties + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "MetricAlertStatusProperties"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + properties: Optional["_models.MetricAlertStatusProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The status name. + :paramtype name: str + :keyword id: The alert rule arm id. + :paramtype id: str + :keyword type: The extended resource type name. + :paramtype type: str + :keyword properties: The alert status properties of the metric alert status. + :paramtype properties: ~azure.mgmt.monitor.models.MetricAlertStatusProperties + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.type = type + self.properties = properties + + +class MetricAlertStatusCollection(_serialization.Model): + """Represents a collection of alert rule resources. + + :ivar value: the values for the alert rule resources. + :vartype value: list[~azure.mgmt.monitor.models.MetricAlertStatus] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MetricAlertStatus]"}, + } + + def __init__(self, *, value: Optional[List["_models.MetricAlertStatus"]] = None, **kwargs: Any) -> None: + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~azure.mgmt.monitor.models.MetricAlertStatus] + """ + super().__init__(**kwargs) + self.value = value + + +class MetricAlertStatusProperties(_serialization.Model): + """An alert status properties. + + :ivar dimensions: An object describing the type of the dimensions. + :vartype dimensions: dict[str, str] + :ivar status: status value. + :vartype status: str + :ivar timestamp: UTC time when the status was checked. + :vartype timestamp: ~datetime.datetime + """ + + _attribute_map = { + "dimensions": {"key": "dimensions", "type": "{str}"}, + "status": {"key": "status", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + } + + def __init__( + self, + *, + dimensions: Optional[Dict[str, str]] = None, + status: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword dimensions: An object describing the type of the dimensions. + :paramtype dimensions: dict[str, str] + :keyword status: status value. + :paramtype status: str + :keyword timestamp: UTC time when the status was checked. + :paramtype timestamp: ~datetime.datetime + """ + super().__init__(**kwargs) + self.dimensions = dimensions + self.status = status + self.timestamp = timestamp + + +class MetricAvailability(_serialization.Model): + """Metric availability specifies the time grain (aggregation interval or frequency) and the + retention period for that time grain. + + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed + as a duration 'PT1M', 'P1D', etc. + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as + a duration 'PT1M', 'P1D', etc. + :vartype retention: ~datetime.timedelta + """ + + _attribute_map = { + "time_grain": {"key": "timeGrain", "type": "duration"}, + "retention": {"key": "retention", "type": "duration"}, + } + + def __init__( + self, + *, + time_grain: Optional[datetime.timedelta] = None, + retention: Optional[datetime.timedelta] = None, + **kwargs: Any + ) -> None: + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + """ + super().__init__(**kwargs) + self.time_grain = time_grain + self.retention = retention + + +class MetricBaselinesResponse(_serialization.Model): + """A list of metric baselines. + + :ivar value: The list of metric baselines. + :vartype value: list[~azure.mgmt.monitor.models.SingleMetricBaseline] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SingleMetricBaseline]"}, + } + + def __init__(self, *, value: Optional[List["_models.SingleMetricBaseline"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of metric baselines. + :paramtype value: list[~azure.mgmt.monitor.models.SingleMetricBaseline] + """ + super().__init__(**kwargs) + self.value = value + + +class MetricCriteria(MultiMetricCriteria): + """Criterion to filter metrics. + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: + "StaticThresholdCriterion" and "DynamicThresholdCriterion". + :vartype criterion_type: str or ~azure.mgmt.monitor.models.CriterionType + :ivar name: Name of the criteria. Required. + :vartype name: str + :ivar metric_name: Name of the metric. Required. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". + :vartype time_aggregation: str or ~azure.mgmt.monitor.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~azure.mgmt.monitor.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + emitted, by causing the metric validation to be skipped. + :vartype skip_metric_validation: bool + :ivar operator: the criteria operator. Required. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual", and "Include". + :vartype operator: str or ~azure.mgmt.monitor.models.Operator + :ivar threshold: the criteria threshold value that activates the alert. Required. + :vartype threshold: float + """ + + _validation = { + "criterion_type": {"required": True}, + "name": {"required": True}, + "metric_name": {"required": True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "criterion_type": {"key": "criterionType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + } + + def __init__( + self, + *, + name: str, + metric_name: str, + time_aggregation: Union[str, "_models.AggregationTypeEnum"], + operator: Union[str, "_models.Operator"], + threshold: float, + additional_properties: Optional[Dict[str, JSON]] = None, + metric_namespace: Optional[str] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, + skip_metric_validation: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + :keyword name: Name of the criteria. Required. + :paramtype name: str + :keyword metric_name: Name of the metric. Required. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: + "Average", "Count", "Minimum", "Maximum", and "Total". + :paramtype time_aggregation: str or ~azure.mgmt.monitor.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~azure.mgmt.monitor.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + :keyword operator: the criteria operator. Required. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual", and "Include". + :paramtype operator: str or ~azure.mgmt.monitor.models.Operator + :keyword threshold: the criteria threshold value that activates the alert. Required. + :paramtype threshold: float + """ + super().__init__( + additional_properties=additional_properties, + name=name, + metric_name=metric_name, + metric_namespace=metric_namespace, + time_aggregation=time_aggregation, + dimensions=dimensions, + skip_metric_validation=skip_metric_validation, + **kwargs + ) + self.criterion_type: str = "StaticThresholdCriterion" + self.operator = operator + self.threshold = threshold + + +class MetricDefinition(_serialization.Model): + """Metric definition class specifies the metadata for a metric. + + :ivar is_dimension_required: Flag to indicate whether the dimension is required. + :vartype is_dimension_required: bool + :ivar resource_id: the resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar namespace: the namespace the metric belongs to. + :vartype namespace: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~azure.mgmt.monitor.models.LocalizableStringAutoGenerated + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar category: Custom category name for this metric. + :vartype category: str + :ivar metric_class: The class of the metric. Known values are: "Availability", "Transactions", + "Errors", "Latency", and "Saturation". + :vartype metric_class: str or ~azure.mgmt.monitor.models.MetricClass + :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". + :vartype unit: str or ~azure.mgmt.monitor.models.MetricUnit + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and + "Total". + :vartype primary_aggregation_type: str or ~azure.mgmt.monitor.models.AggregationType + :ivar supported_aggregation_types: the collection of what aggregation types are supported. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.monitor.models.AggregationType] + :ivar metric_availabilities: the collection of what aggregation intervals are available to be + queried. + :vartype metric_availabilities: list[~azure.mgmt.monitor.models.MetricAvailability] + :ivar id: the resource identifier of the metric definition. + :vartype id: str + :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable + string. + :vartype dimensions: list[~azure.mgmt.monitor.models.LocalizableStringAutoGenerated] + """ + + _attribute_map = { + "is_dimension_required": {"key": "isDimensionRequired", "type": "bool"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "name": {"key": "name", "type": "LocalizableStringAutoGenerated"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "metric_class": {"key": "metricClass", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, + "id": {"key": "id", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[LocalizableStringAutoGenerated]"}, + } + + def __init__( + self, + *, + is_dimension_required: Optional[bool] = None, + resource_id: Optional[str] = None, + namespace: Optional[str] = None, + name: Optional["_models.LocalizableStringAutoGenerated"] = None, + display_description: Optional[str] = None, + category: Optional[str] = None, + metric_class: Optional[Union[str, "_models.MetricClass"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, + metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + dimensions: Optional[List["_models.LocalizableStringAutoGenerated"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_dimension_required: Flag to indicate whether the dimension is required. + :paramtype is_dimension_required: bool + :keyword resource_id: the resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword namespace: the namespace the metric belongs to. + :paramtype namespace: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~azure.mgmt.monitor.models.LocalizableStringAutoGenerated + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword category: Custom category name for this metric. + :paramtype category: str + :keyword metric_class: The class of the metric. Known values are: "Availability", + "Transactions", "Errors", "Latency", and "Saturation". + :paramtype metric_class: str or ~azure.mgmt.monitor.models.MetricClass + :keyword unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". + :paramtype unit: str or ~azure.mgmt.monitor.models.MetricUnit + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and + "Total". + :paramtype primary_aggregation_type: str or ~azure.mgmt.monitor.models.AggregationType + :keyword supported_aggregation_types: the collection of what aggregation types are supported. + :paramtype supported_aggregation_types: list[str or ~azure.mgmt.monitor.models.AggregationType] + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: list[~azure.mgmt.monitor.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable + string. + :paramtype dimensions: list[~azure.mgmt.monitor.models.LocalizableStringAutoGenerated] + """ + super().__init__(**kwargs) + self.is_dimension_required = is_dimension_required + self.resource_id = resource_id + self.namespace = namespace + self.name = name + self.display_description = display_description + self.category = category + self.metric_class = metric_class + self.unit = unit + self.primary_aggregation_type = primary_aggregation_type + self.supported_aggregation_types = supported_aggregation_types + self.metric_availabilities = metric_availabilities + self.id = id + self.dimensions = dimensions + + +class MetricDefinitionCollection(_serialization.Model): + """Represents collection of metric definitions. + + All required parameters must be populated in order to send to server. + + :ivar value: the values for the metric definitions. Required. + :vartype value: list[~azure.mgmt.monitor.models.MetricDefinition] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[MetricDefinition]"}, + } + + def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: + """ + :keyword value: the values for the metric definitions. Required. + :paramtype value: list[~azure.mgmt.monitor.models.MetricDefinition] + """ + super().__init__(**kwargs) + self.value = value + + +class MetricDimension(_serialization.Model): + """Specifies a metric dimension. + + All required parameters must be populated in order to send to server. + + :ivar name: Name of the dimension. Required. + :vartype name: str + :ivar operator: the dimension operator. Only 'Include' and 'Exclude' are supported. Required. + :vartype operator: str + :ivar values: list of dimension values. Required. + :vartype values: list[str] + """ + + _validation = { + "name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + } + + def __init__(self, *, name: str, operator: str, values: List[str], **kwargs: Any) -> None: + """ + :keyword name: Name of the dimension. Required. + :paramtype name: str + :keyword operator: the dimension operator. Only 'Include' and 'Exclude' are supported. + Required. + :paramtype operator: str + :keyword values: list of dimension values. Required. + :paramtype values: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.operator = operator + self.values = values + + +class MetricNamespace(_serialization.Model): + """Metric namespace class specifies the metadata for a metric namespace. + + :ivar id: The ID of the metric namespace. + :vartype id: str + :ivar type: The type of the namespace. + :vartype type: str + :ivar name: The escaped name of the namespace. + :vartype name: str + :ivar classification: Kind of namespace. Known values are: "Platform", "Custom", and "Qos". + :vartype classification: str or ~azure.mgmt.monitor.models.NamespaceClassification + :ivar properties: Properties which include the fully qualified namespace name. + :vartype properties: ~azure.mgmt.monitor.models.MetricNamespaceName + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "classification": {"key": "classification", "type": "str"}, + "properties": {"key": "properties", "type": "MetricNamespaceName"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + name: Optional[str] = None, + classification: Optional[Union[str, "_models.NamespaceClassification"]] = None, + properties: Optional["_models.MetricNamespaceName"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The ID of the metric namespace. + :paramtype id: str + :keyword type: The type of the namespace. + :paramtype type: str + :keyword name: The escaped name of the namespace. + :paramtype name: str + :keyword classification: Kind of namespace. Known values are: "Platform", "Custom", and "Qos". + :paramtype classification: str or ~azure.mgmt.monitor.models.NamespaceClassification + :keyword properties: Properties which include the fully qualified namespace name. + :paramtype properties: ~azure.mgmt.monitor.models.MetricNamespaceName + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.name = name + self.classification = classification + self.properties = properties + + +class MetricNamespaceCollection(_serialization.Model): + """Represents collection of metric namespaces. + + All required parameters must be populated in order to send to server. + + :ivar value: The values for the metric namespaces. Required. + :vartype value: list[~azure.mgmt.monitor.models.MetricNamespace] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[MetricNamespace]"}, + } + + def __init__(self, *, value: List["_models.MetricNamespace"], **kwargs: Any) -> None: + """ + :keyword value: The values for the metric namespaces. Required. + :paramtype value: list[~azure.mgmt.monitor.models.MetricNamespace] + """ + super().__init__(**kwargs) + self.value = value + + +class MetricNamespaceName(_serialization.Model): + """The fully qualified metric namespace name. + + :ivar metric_namespace_name: The metric namespace name. + :vartype metric_namespace_name: str + """ + + _attribute_map = { + "metric_namespace_name": {"key": "metricNamespaceName", "type": "str"}, + } + + def __init__(self, *, metric_namespace_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword metric_namespace_name: The metric namespace name. + :paramtype metric_namespace_name: str + """ + super().__init__(**kwargs) + self.metric_namespace_name = metric_namespace_name + + +class MetricSettings(_serialization.Model): + """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. + + All required parameters must be populated in order to send to server. + + :ivar time_grain: the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar category: 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. + :vartype category: str + :ivar enabled: a value indicating whether this category is enabled. Required. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this category. + :vartype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "time_grain": {"key": "timeGrain", "type": "duration"}, + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + } + + def __init__( + self, + *, + enabled: bool, + time_grain: Optional[datetime.timedelta] = None, + category: Optional[str] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword time_grain: the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword category: 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. + :paramtype category: str + :keyword enabled: a value indicating whether this category is enabled. Required. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this category. + :paramtype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + super().__init__(**kwargs) + self.time_grain = time_grain + self.category = category + self.enabled = enabled + self.retention_policy = retention_policy + + +class MetricSettingsAutoGenerated(_serialization.Model): + """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. + + All required parameters must be populated in order to send to server. + + :ivar time_grain: the timegrain of the metric in ISO8601 format. Required. + :vartype time_grain: ~datetime.timedelta + :ivar enabled: a value indicating whether this timegrain is enabled. Required. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this timegrain. + :vartype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + + _validation = { + "time_grain": {"required": True}, + "enabled": {"required": True}, + } + + _attribute_map = { + "time_grain": {"key": "timeGrain", "type": "duration"}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, + } + + def __init__( + self, + *, + time_grain: datetime.timedelta, + enabled: bool, + retention_policy: Optional["_models.RetentionPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword time_grain: the timegrain of the metric in ISO8601 format. Required. + :paramtype time_grain: ~datetime.timedelta + :keyword enabled: a value indicating whether this timegrain is enabled. Required. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this timegrain. + :paramtype retention_policy: ~azure.mgmt.monitor.models.RetentionPolicy + """ + super().__init__(**kwargs) + self.time_grain = time_grain + self.enabled = enabled + self.retention_policy = retention_policy + + +class MetricSingleDimension(_serialization.Model): + """The metric dimension name and value. + + All required parameters must be populated in order to send to server. + + :ivar name: Name of the dimension. Required. + :vartype name: str + :ivar value: Value of the dimension. Required. + :vartype value: str + """ + + _validation = { + "name": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: + """ + :keyword name: Name of the dimension. Required. + :paramtype name: str + :keyword value: Value of the dimension. Required. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class MetricTrigger(_serialization.Model): + """The trigger that results in a scaling action. + + All required parameters must be populated in order to send to server. + + :ivar metric_name: the name of the metric that defines what the rule monitors. Required. + :vartype metric_name: str + :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. + :vartype metric_namespace: str + :ivar metric_resource_uri: the resource identifier of the resource the rule monitors. Required. + :vartype metric_resource_uri: str + :ivar metric_resource_location: the location of the resource the rule monitors. + :vartype metric_resource_location: str + :ivar time_grain: 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. + Required. + :vartype time_grain: ~datetime.timedelta + :ivar statistic: the metric statistic type. How the metrics from multiple instances are + combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". + :vartype statistic: str or ~azure.mgmt.monitor.models.MetricStatisticType + :ivar time_window: 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. Required. + :vartype time_window: ~datetime.timedelta + :ivar time_aggregation: time aggregation type. How the data that is collected should be + combined over time. The default value is Average. Required. Known values are: "Average", + "Minimum", "Maximum", "Total", "Count", and "Last". + :vartype time_aggregation: str or ~azure.mgmt.monitor.models.TimeAggregationType + :ivar operator: the operator that is used to compare the metric data and the threshold. + Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", and "LessThanOrEqual". + :vartype operator: str or ~azure.mgmt.monitor.models.ComparisonOperationType + :ivar threshold: the threshold of the metric that triggers the scale action. Required. + :vartype threshold: float + :ivar dimensions: List of dimension conditions. For example: + [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. # pylint: disable=line-too-long + :vartype dimensions: list[~azure.mgmt.monitor.models.ScaleRuleMetricDimension] + :ivar divide_per_instance: a value indicating whether metric should divide per instance. + :vartype divide_per_instance: bool + """ + + _validation = { + "metric_name": {"required": True}, + "metric_resource_uri": {"required": True}, + "time_grain": {"required": True}, + "statistic": {"required": True}, + "time_window": {"required": True}, + "time_aggregation": {"required": True}, + "operator": {"required": True}, + "threshold": {"required": True}, + } + + _attribute_map = { + "metric_name": {"key": "metricName", "type": "str"}, + "metric_namespace": {"key": "metricNamespace", "type": "str"}, + "metric_resource_uri": {"key": "metricResourceUri", "type": "str"}, + "metric_resource_location": {"key": "metricResourceLocation", "type": "str"}, + "time_grain": {"key": "timeGrain", "type": "duration"}, + "statistic": {"key": "statistic", "type": "str"}, + "time_window": {"key": "timeWindow", "type": "duration"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "dimensions": {"key": "dimensions", "type": "[ScaleRuleMetricDimension]"}, + "divide_per_instance": {"key": "dividePerInstance", "type": "bool"}, + } + + def __init__( + self, + *, + metric_name: str, + metric_resource_uri: str, + time_grain: datetime.timedelta, + statistic: Union[str, "_models.MetricStatisticType"], + time_window: datetime.timedelta, + time_aggregation: Union[str, "_models.TimeAggregationType"], + operator: Union[str, "_models.ComparisonOperationType"], + threshold: float, + metric_namespace: Optional[str] = None, + metric_resource_location: Optional[str] = None, + dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, + divide_per_instance: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword metric_name: the name of the metric that defines what the rule monitors. Required. + :paramtype metric_name: str + :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. + :paramtype metric_namespace: str + :keyword metric_resource_uri: the resource identifier of the resource the rule monitors. + Required. + :paramtype metric_resource_uri: str + :keyword metric_resource_location: the location of the resource the rule monitors. + :paramtype metric_resource_location: str + :keyword time_grain: 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. Required. + :paramtype time_grain: ~datetime.timedelta + :keyword statistic: the metric statistic type. How the metrics from multiple instances are + combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". + :paramtype statistic: str or ~azure.mgmt.monitor.models.MetricStatisticType + :keyword time_window: 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. Required. + :paramtype time_window: ~datetime.timedelta + :keyword time_aggregation: time aggregation type. How the data that is collected should be + combined over time. The default value is Average. Required. Known values are: "Average", + "Minimum", "Maximum", "Total", "Count", and "Last". + :paramtype time_aggregation: str or ~azure.mgmt.monitor.models.TimeAggregationType + :keyword operator: the operator that is used to compare the metric data and the threshold. + Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", and "LessThanOrEqual". + :paramtype operator: str or ~azure.mgmt.monitor.models.ComparisonOperationType + :keyword threshold: the threshold of the metric that triggers the scale action. Required. + :paramtype threshold: float + :keyword dimensions: List of dimension conditions. For example: + [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. # pylint: disable=line-too-long + :paramtype dimensions: list[~azure.mgmt.monitor.models.ScaleRuleMetricDimension] + :keyword divide_per_instance: a value indicating whether metric should divide per instance. + :paramtype divide_per_instance: bool + """ + super().__init__(**kwargs) + self.metric_name = metric_name + self.metric_namespace = metric_namespace + self.metric_resource_uri = metric_resource_uri + self.metric_resource_location = metric_resource_location + self.time_grain = time_grain + self.statistic = statistic + self.time_window = time_window + self.time_aggregation = time_aggregation + self.operator = operator + self.threshold = threshold + self.dimensions = dimensions + self.divide_per_instance = divide_per_instance + + +class MetricValue(_serialization.Model): + """Represents a metric value. + + All required parameters must be populated in order to send to server. + + :ivar time_stamp: The timestamp for the metric value in ISO 8601 format. Required. + :vartype time_stamp: ~datetime.datetime + :ivar average: The average value in the time range. + :vartype average: float + :ivar minimum: The least value in the time range. + :vartype minimum: float + :ivar maximum: The greatest value in the time range. + :vartype maximum: float + :ivar total: The sum of all of the values in the time range. + :vartype total: float + :ivar count: The number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :vartype count: float + """ + + _validation = { + "time_stamp": {"required": True}, + } + + _attribute_map = { + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "average": {"key": "average", "type": "float"}, + "minimum": {"key": "minimum", "type": "float"}, + "maximum": {"key": "maximum", "type": "float"}, + "total": {"key": "total", "type": "float"}, + "count": {"key": "count", "type": "float"}, + } + + def __init__( + self, + *, + time_stamp: datetime.datetime, + average: Optional[float] = None, + minimum: Optional[float] = None, + maximum: Optional[float] = None, + total: Optional[float] = None, + count: Optional[float] = None, + **kwargs: Any + ) -> None: + """ + :keyword time_stamp: The timestamp for the metric value in ISO 8601 format. Required. + :paramtype time_stamp: ~datetime.datetime + :keyword average: The average value in the time range. + :paramtype average: float + :keyword minimum: The least value in the time range. + :paramtype minimum: float + :keyword maximum: The greatest value in the time range. + :paramtype maximum: float + :keyword total: The sum of all of the values in the time range. + :paramtype total: float + :keyword count: The number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :paramtype count: float + """ + super().__init__(**kwargs) + self.time_stamp = time_stamp + self.average = average + self.minimum = minimum + self.maximum = maximum + self.total = total + self.count = count + + +class NotificationRequestBody(_serialization.Model): + """The request body which contain contact detail metadata. + + All required parameters must be populated in order to send to server. + + :ivar alert_type: The value of the supported alert type. Supported alert type values are: + servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, + webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, + actualcostbudget, forecastedbudget. Required. + :vartype alert_type: str + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~azure.mgmt.monitor.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~azure.mgmt.monitor.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~azure.mgmt.monitor.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~azure.mgmt.monitor.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~azure.mgmt.monitor.models.AzureAppPushReceiver] + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :vartype automation_runbook_receivers: + list[~azure.mgmt.monitor.models.AutomationRunbookReceiver] + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~azure.mgmt.monitor.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: list[~azure.mgmt.monitor.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this + action group. + :vartype azure_function_receivers: list[~azure.mgmt.monitor.models.AzureFunctionReceiver] + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :vartype arm_role_receivers: list[~azure.mgmt.monitor.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: list[~azure.mgmt.monitor.models.EventHubReceiver] + """ + + _validation = { + "alert_type": {"required": True, "max_length": 30}, + } + + _attribute_map = { + "alert_type": {"key": "alertType", "type": "str"}, + "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, + "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, + "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, + "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, + "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, + "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, + "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, + "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, + "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, + "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, + "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, + } + + def __init__( + self, + *, + alert_type: str, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, + arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, + event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword alert_type: The value of the supported alert type. Supported alert type values are: + servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, + webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, + actualcostbudget, forecastedbudget. Required. + :paramtype alert_type: str + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~azure.mgmt.monitor.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~azure.mgmt.monitor.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: list[~azure.mgmt.monitor.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~azure.mgmt.monitor.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: list[~azure.mgmt.monitor.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~azure.mgmt.monitor.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~azure.mgmt.monitor.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: list[~azure.mgmt.monitor.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: list[~azure.mgmt.monitor.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: list[~azure.mgmt.monitor.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: list[~azure.mgmt.monitor.models.EventHubReceiver] + """ + super().__init__(**kwargs) + self.alert_type = alert_type + self.email_receivers = email_receivers + self.sms_receivers = sms_receivers + self.webhook_receivers = webhook_receivers + self.itsm_receivers = itsm_receivers + self.azure_app_push_receivers = azure_app_push_receivers + self.automation_runbook_receivers = automation_runbook_receivers + self.voice_receivers = voice_receivers + self.logic_app_receivers = logic_app_receivers + self.azure_function_receivers = azure_function_receivers + self.arm_role_receivers = arm_role_receivers + self.event_hub_receivers = event_hub_receivers + + +class Operation(_serialization.Model): + """Microsoft Insights API operation definition. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.monitor.models.OperationDisplay + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + } + + def __init__( + self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any + ) -> None: + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.monitor.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(_serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Service provider: Microsoft.Insights. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword provider: Service provider: Microsoft.Insights. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + + +class OperationListResult(_serialization.Model): + """Result of the request to list Microsoft.Insights operations. It contains a list of operations + and a URL link to get the next set of results. + + :ivar value: List of operations supported by the Microsoft.Insights provider. + :vartype value: list[~azure.mgmt.monitor.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: List of operations supported by the Microsoft.Insights provider. + :paramtype value: list[~azure.mgmt.monitor.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationStatus(_serialization.Model): + """The status of operation. + + :ivar id: The operation Id. + :vartype id: str + :ivar name: The operation name. + :vartype name: str + :ivar start_time: Start time of the job in standard ISO8601 format. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the job in standard ISO8601 format. + :vartype end_time: ~datetime.datetime + :ivar status: The status of the operation. + :vartype status: str + :ivar error: The error detail of the operation if any. + :vartype error: ~azure.mgmt.monitor.models.ErrorResponseCommon + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponseCommon"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + status: Optional[str] = None, + error: Optional["_models.ErrorResponseCommon"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The operation Id. + :paramtype id: str + :keyword name: The operation name. + :paramtype name: str + :keyword start_time: Start time of the job in standard ISO8601 format. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the job in standard ISO8601 format. + :paramtype end_time: ~datetime.datetime + :keyword status: The status of the operation. + :paramtype status: str + :keyword error: The error detail of the operation if any. + :paramtype error: ~azure.mgmt.monitor.models.ErrorResponseCommon + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.start_time = start_time + self.end_time = end_time + self.status = status + self.error = error + + +class PerformanceCounterConfiguration(_serialization.Model): + """PerformanceCounterConfiguration. + + All required parameters must be populated in order to send to server. + + :ivar name: Required. + :vartype name: str + :ivar sampling_period: Required. + :vartype sampling_period: str + :ivar instance: + :vartype instance: str + """ + + _validation = { + "name": {"required": True}, + "sampling_period": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "sampling_period": {"key": "samplingPeriod", "type": "str"}, + "instance": {"key": "instance", "type": "str"}, + } + + def __init__(self, *, name: str, sampling_period: str, instance: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: Required. + :paramtype name: str + :keyword sampling_period: Required. + :paramtype sampling_period: str + :keyword instance: + :paramtype instance: str + """ + super().__init__(**kwargs) + self.name = name + self.sampling_period = sampling_period + self.instance = instance + + +class PredictiveAutoscalePolicy(_serialization.Model): + """The parameters for enabling predictive autoscale. + + All required parameters must be populated in order to send to server. + + :ivar scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", + "ForecastOnly", and "Enabled". + :vartype scale_mode: str or ~azure.mgmt.monitor.models.PredictiveAutoscalePolicyScaleMode + :ivar scale_look_ahead_time: the amount of time to specify by which instances are launched in + advance. It must be between 1 minute and 60 minutes in ISO 8601 format. + :vartype scale_look_ahead_time: ~datetime.timedelta + """ + + _validation = { + "scale_mode": {"required": True}, + } + + _attribute_map = { + "scale_mode": {"key": "scaleMode", "type": "str"}, + "scale_look_ahead_time": {"key": "scaleLookAheadTime", "type": "duration"}, + } + + def __init__( + self, + *, + scale_mode: Union[str, "_models.PredictiveAutoscalePolicyScaleMode"], + scale_look_ahead_time: Optional[datetime.timedelta] = None, + **kwargs: Any + ) -> None: + """ + :keyword scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", + "ForecastOnly", and "Enabled". + :paramtype scale_mode: str or ~azure.mgmt.monitor.models.PredictiveAutoscalePolicyScaleMode + :keyword scale_look_ahead_time: the amount of time to specify by which instances are launched + in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. + :paramtype scale_look_ahead_time: ~datetime.timedelta + """ + super().__init__(**kwargs) + self.scale_mode = scale_mode + self.scale_look_ahead_time = scale_look_ahead_time + + +class PredictiveResponse(_serialization.Model): + """The response to a metrics query. + + :ivar timespan: 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. + :vartype timespan: str + :ivar interval: 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. + :vartype interval: ~datetime.timedelta + :ivar metric_name: The metrics being queried. + :vartype metric_name: str + :ivar target_resource_id: resource of the predictive metric. + :vartype target_resource_id: str + :ivar data: the value of the collection. + :vartype data: list[~azure.mgmt.monitor.models.PredictiveValue] + """ + + _attribute_map = { + "timespan": {"key": "timespan", "type": "str"}, + "interval": {"key": "interval", "type": "duration"}, + "metric_name": {"key": "metricName", "type": "str"}, + "target_resource_id": {"key": "targetResourceId", "type": "str"}, + "data": {"key": "data", "type": "[PredictiveValue]"}, + } + + def __init__( + self, + *, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + metric_name: Optional[str] = None, + target_resource_id: Optional[str] = None, + data: Optional[List["_models.PredictiveValue"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword timespan: 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. + :paramtype timespan: str + :keyword interval: 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. + :paramtype interval: ~datetime.timedelta + :keyword metric_name: The metrics being queried. + :paramtype metric_name: str + :keyword target_resource_id: resource of the predictive metric. + :paramtype target_resource_id: str + :keyword data: the value of the collection. + :paramtype data: list[~azure.mgmt.monitor.models.PredictiveValue] + """ + super().__init__(**kwargs) + self.timespan = timespan + self.interval = interval + self.metric_name = metric_name + self.target_resource_id = target_resource_id + self.data = data + + +class PredictiveValue(_serialization.Model): + """Represents a predictive metric value in the given bucket. + + All required parameters must be populated in order to send to server. + + :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. + :vartype time_stamp: ~datetime.datetime + :ivar value: Predictive value in this time bucket. Required. + :vartype value: float + """ + + _validation = { + "time_stamp": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "value": {"key": "value", "type": "float"}, + } + + def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs: Any) -> None: + """ + :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. + :paramtype time_stamp: ~datetime.datetime + :keyword value: Predictive value in this time bucket. Required. + :paramtype value: float + """ + super().__init__(**kwargs) + self.time_stamp = time_stamp + self.value = value + + +class ProxyResource(_serialization.Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class PrivateEndpointConnection(ProxyResource): + """A private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.monitor.models.PrivateEndpointProperty + :ivar private_link_service_connection_state: Connection state of the private endpoint + connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.monitor.models.PrivateLinkServiceConnectionStateProperty + :ivar provisioning_state: State of the private endpoint connection. + :vartype provisioning_state: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionStateProperty", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: ~azure.mgmt.monitor.models.PrivateEndpointProperty + :keyword private_link_service_connection_state: Connection state of the private endpoint + connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.monitor.models.PrivateLinkServiceConnectionStateProperty + """ + super().__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """A list of private endpoint connections. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateEndpointProperty(_serialization.Model): + """Private endpoint which the connection belongs to. + + :ivar id: Resource id of the private endpoint. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: Resource id of the private endpoint. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class PrivateLinkResource(ProxyResource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.group_id = None + self.required_members = None + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.monitor.models.PrivateLinkResource] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateLinkServiceConnectionStateProperty(_serialization.Model): # pylint: disable=name-too-long + """State of the private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar status: The private link service connection status. Required. + :vartype status: str + :ivar description: The private link service connection description. Required. + :vartype description: str + :ivar actions_required: The actions required for private link service connection. + :vartype actions_required: str + """ + + _validation = { + "status": {"required": True}, + "description": {"required": True}, + "actions_required": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__(self, *, status: str, description: str, **kwargs: Any) -> None: + """ + :keyword status: The private link service connection status. Required. + :paramtype status: str + :keyword description: The private link service connection description. Required. + :paramtype description: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = None + + +class Recurrence(_serialization.Model): + """The repeating times at which this profile begins. This element is not used if the FixedDate + element is used. + + All required parameters must be populated in order to send to server. + + :ivar frequency: 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. Required. Known values are: "None", "Second", + "Minute", "Hour", "Day", "Week", "Month", and "Year". + :vartype frequency: str or ~azure.mgmt.monitor.models.RecurrenceFrequency + :ivar schedule: the scheduling constraints for when the profile begins. Required. + :vartype schedule: ~azure.mgmt.monitor.models.RecurrentSchedule + """ + + _validation = { + "frequency": {"required": True}, + "schedule": {"required": True}, + } + + _attribute_map = { + "frequency": {"key": "frequency", "type": "str"}, + "schedule": {"key": "schedule", "type": "RecurrentSchedule"}, + } + + def __init__( + self, + *, + frequency: Union[str, "_models.RecurrenceFrequency"], + schedule: "_models.RecurrentSchedule", + **kwargs: Any + ) -> None: + """ + :keyword frequency: 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. Required. Known values are: "None", + "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year". + :paramtype frequency: str or ~azure.mgmt.monitor.models.RecurrenceFrequency + :keyword schedule: the scheduling constraints for when the profile begins. Required. + :paramtype schedule: ~azure.mgmt.monitor.models.RecurrentSchedule + """ + super().__init__(**kwargs) + self.frequency = frequency + self.schedule = schedule + + +class RecurrentSchedule(_serialization.Model): + """The scheduling constraints for when the profile begins. + + All required parameters must be populated in order to send to server. + + :ivar time_zone: 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. Required. + :vartype time_zone: str + :ivar days: the collection of days that the profile takes effect on. Possible values are Sunday + through Saturday. Required. + :vartype days: list[str] + :ivar hours: 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). Required. + :vartype hours: list[int] + :ivar minutes: A collection of minutes at which the profile takes effect at. Required. + :vartype minutes: list[int] + """ + + _validation = { + "time_zone": {"required": True}, + "days": {"required": True}, + "hours": {"required": True}, + "minutes": {"required": True}, + } + + _attribute_map = { + "time_zone": {"key": "timeZone", "type": "str"}, + "days": {"key": "days", "type": "[str]"}, + "hours": {"key": "hours", "type": "[int]"}, + "minutes": {"key": "minutes", "type": "[int]"}, + } + + def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any) -> None: + """ + :keyword time_zone: 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. Required. + :paramtype time_zone: str + :keyword days: the collection of days that the profile takes effect on. Possible values are + Sunday through Saturday. Required. + :paramtype days: list[str] + :keyword hours: 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). Required. + :paramtype hours: list[int] + :keyword minutes: A collection of minutes at which the profile takes effect at. Required. + :paramtype minutes: list[int] + """ + super().__init__(**kwargs) + self.time_zone = time_zone + self.days = days + self.hours = hours + self.minutes = minutes + + +class Response(_serialization.Model): + """The response to a metrics query. + + All required parameters must be populated in order to send to server. + + :ivar cost: The integer value representing the relative cost of the query. + :vartype cost: int + :ivar timespan: 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. Required. + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in ISO 8601 + duration format with a special case for 'FULL' value that returns single datapoint for entire + time span requested (\\ *Examples: PT15M, PT1H, P1D, FULL*\\ ). + This may be adjusted and different from what was originally requested if + AutoAdjustTimegrain=true is specified. This is not present if a metadata request was made. + :vartype interval: str + :ivar namespace: The namespace of the metrics being queried. + :vartype namespace: str + :ivar resourceregion: The region of the resource being queried for metrics. + :vartype resourceregion: str + :ivar value: the value of the collection. Required. + :vartype value: list[~azure.mgmt.monitor.models.Metric] + """ + + _validation = { + "cost": {"minimum": 0}, + "timespan": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "cost": {"key": "cost", "type": "int"}, + "timespan": {"key": "timespan", "type": "str"}, + "interval": {"key": "interval", "type": "str"}, + "namespace": {"key": "namespace", "type": "str"}, + "resourceregion": {"key": "resourceregion", "type": "str"}, + "value": {"key": "value", "type": "[Metric]"}, + } + + def __init__( + self, + *, + timespan: str, + value: List["_models.Metric"], + cost: Optional[int] = None, + interval: Optional[str] = None, + namespace: Optional[str] = None, + resourceregion: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword cost: The integer value representing the relative cost of the query. + :paramtype cost: int + :keyword timespan: 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. Required. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in ISO + 8601 duration format with a special case for 'FULL' value that returns single datapoint for + entire time span requested (\\ *Examples: PT15M, PT1H, P1D, FULL*\\ ). + This may be adjusted and different from what was originally requested if + AutoAdjustTimegrain=true is specified. This is not present if a metadata request was made. + :paramtype interval: str + :keyword namespace: The namespace of the metrics being queried. + :paramtype namespace: str + :keyword resourceregion: The region of the resource being queried for metrics. + :paramtype resourceregion: str + :keyword value: the value of the collection. Required. + :paramtype value: list[~azure.mgmt.monitor.models.Metric] + """ + super().__init__(**kwargs) + self.cost = cost + self.timespan = timespan + self.interval = interval + self.namespace = namespace + self.resourceregion = resourceregion + self.value = value + + +class ResponseWithError(_serialization.Model): + """An error response from the API. + + All required parameters must be populated in order to send to server. + + :ivar error: Error information. Required. + :vartype error: ~azure.mgmt.monitor.models.Error + """ + + _validation = { + "error": {"required": True}, + } + + _attribute_map = { + "error": {"key": "error", "type": "Error"}, + } + + def __init__(self, *, error: "_models.Error", **kwargs: Any) -> None: + """ + :keyword error: Error information. Required. + :paramtype error: ~azure.mgmt.monitor.models.Error + """ + super().__init__(**kwargs) + self.error = error + + +class RetentionPolicy(_serialization.Model): + """Specifies the retention policy for the log. + + All required parameters must be populated in order to send to server. + + :ivar enabled: a value indicating whether the retention policy is enabled. Required. + :vartype enabled: bool + :ivar days: the number of days for the retention in days. A value of 0 will retain the events + indefinitely. Required. + :vartype days: int + """ + + _validation = { + "enabled": {"required": True}, + "days": {"required": True, "minimum": 0}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + } + + def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: + """ + :keyword enabled: a value indicating whether the retention policy is enabled. Required. + :paramtype enabled: bool + :keyword days: the number of days for the retention in days. A value of 0 will retain the + events indefinitely. Required. + :paramtype days: int + """ + super().__init__(**kwargs) + self.enabled = enabled + self.days = days + + +class ScaleAction(_serialization.Model): + """The parameters for the scaling action. + + All required parameters must be populated in order to send to server. + + :ivar direction: the scale direction. Whether the scaling action increases or decreases the + number of instances. Required. Known values are: "None", "Increase", and "Decrease". + :vartype direction: str or ~azure.mgmt.monitor.models.ScaleDirection + :ivar type: the type of action that should occur when the scale rule fires. Required. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". + :vartype type: str or ~azure.mgmt.monitor.models.ScaleType + :ivar value: the number of instances that are involved in the scaling action. This value must + be 1 or greater. The default value is 1. + :vartype value: str + :ivar cooldown: 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. Required. + :vartype cooldown: ~datetime.timedelta + """ + + _validation = { + "direction": {"required": True}, + "type": {"required": True}, + "cooldown": {"required": True}, + } + + _attribute_map = { + "direction": {"key": "direction", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "cooldown": {"key": "cooldown", "type": "duration"}, + } + + def __init__( + self, + *, + direction: Union[str, "_models.ScaleDirection"], + type: Union[str, "_models.ScaleType"], + cooldown: datetime.timedelta, + value: str = "1", + **kwargs: Any + ) -> None: + """ + :keyword direction: the scale direction. Whether the scaling action increases or decreases the + number of instances. Required. Known values are: "None", "Increase", and "Decrease". + :paramtype direction: str or ~azure.mgmt.monitor.models.ScaleDirection + :keyword type: the type of action that should occur when the scale rule fires. Required. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". + :paramtype type: str or ~azure.mgmt.monitor.models.ScaleType + :keyword value: the number of instances that are involved in the scaling action. This value + must be 1 or greater. The default value is 1. + :paramtype value: str + :keyword cooldown: 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. Required. + :paramtype cooldown: ~datetime.timedelta + """ + super().__init__(**kwargs) + self.direction = direction + self.type = type + self.value = value + self.cooldown = cooldown + + +class ScaleCapacity(_serialization.Model): + """The number of instances that can be used during this profile. + + All required parameters must be populated in order to send to server. + + :ivar minimum: the minimum number of instances for the resource. Required. + :vartype minimum: str + :ivar maximum: 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. Required. + :vartype maximum: str + :ivar default: 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. + Required. + :vartype default: str + """ + + _validation = { + "minimum": {"required": True}, + "maximum": {"required": True}, + "default": {"required": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "str"}, + "maximum": {"key": "maximum", "type": "str"}, + "default": {"key": "default", "type": "str"}, + } + + def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs: Any) -> None: + """ + :keyword minimum: the minimum number of instances for the resource. Required. + :paramtype minimum: str + :keyword maximum: 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. Required. + :paramtype maximum: str + :keyword default: 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. + Required. + :paramtype default: str + """ + super().__init__(**kwargs) + self.minimum = minimum + self.maximum = maximum + self.default = default + + +class ScaleRule(_serialization.Model): + """A rule that provide the triggers and parameters for the scaling action. + + All required parameters must be populated in order to send to server. + + :ivar metric_trigger: the trigger that results in a scaling action. Required. + :vartype metric_trigger: ~azure.mgmt.monitor.models.MetricTrigger + :ivar scale_action: the parameters for the scaling action. Required. + :vartype scale_action: ~azure.mgmt.monitor.models.ScaleAction + """ + + _validation = { + "metric_trigger": {"required": True}, + "scale_action": {"required": True}, + } + + _attribute_map = { + "metric_trigger": {"key": "metricTrigger", "type": "MetricTrigger"}, + "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, + } + + def __init__( + self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs: Any + ) -> None: + """ + :keyword metric_trigger: the trigger that results in a scaling action. Required. + :paramtype metric_trigger: ~azure.mgmt.monitor.models.MetricTrigger + :keyword scale_action: the parameters for the scaling action. Required. + :paramtype scale_action: ~azure.mgmt.monitor.models.ScaleAction + """ + super().__init__(**kwargs) + self.metric_trigger = metric_trigger + self.scale_action = scale_action + + +class ScaleRuleMetricDimension(_serialization.Model): + """Specifies an auto scale rule metric dimension. + + All required parameters must be populated in order to send to server. + + :ivar dimension_name: Name of the dimension. Required. + :vartype dimension_name: str + :ivar operator: 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. Required. + Known values are: "Equals" and "NotEquals". + :vartype operator: str or ~azure.mgmt.monitor.models.ScaleRuleMetricDimensionOperationType + :ivar values: list of dimension values. For example: ["App1","App2"]. Required. + :vartype values: list[str] + """ + + _validation = { + "dimension_name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, + } + + _attribute_map = { + "dimension_name": {"key": "DimensionName", "type": "str"}, + "operator": {"key": "Operator", "type": "str"}, + "values": {"key": "Values", "type": "[str]"}, + } + + def __init__( + self, + *, + dimension_name: str, + operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], + values: List[str], + **kwargs: Any + ) -> None: + """ + :keyword dimension_name: Name of the dimension. Required. + :paramtype dimension_name: str + :keyword operator: 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. + Required. Known values are: "Equals" and "NotEquals". + :paramtype operator: str or ~azure.mgmt.monitor.models.ScaleRuleMetricDimensionOperationType + :keyword values: list of dimension values. For example: ["App1","App2"]. Required. + :paramtype values: list[str] + """ + super().__init__(**kwargs) + self.dimension_name = dimension_name + self.operator = operator + self.values = values + + +class Schedule(_serialization.Model): + """Defines how often to run the search and the time interval. + + All required parameters must be populated in order to send to server. + + :ivar frequency_in_minutes: frequency (in minutes) at which rule condition should be evaluated. + Required. + :vartype frequency_in_minutes: int + :ivar time_window_in_minutes: Time window for which data needs to be fetched for query (should + be greater than or equal to frequencyInMinutes). Required. + :vartype time_window_in_minutes: int + """ + + _validation = { + "frequency_in_minutes": {"required": True}, + "time_window_in_minutes": {"required": True}, + } + + _attribute_map = { + "frequency_in_minutes": {"key": "frequencyInMinutes", "type": "int"}, + "time_window_in_minutes": {"key": "timeWindowInMinutes", "type": "int"}, + } + + def __init__(self, *, frequency_in_minutes: int, time_window_in_minutes: int, **kwargs: Any) -> None: + """ + :keyword frequency_in_minutes: frequency (in minutes) at which rule condition should be + evaluated. Required. + :paramtype frequency_in_minutes: int + :keyword time_window_in_minutes: Time window for which data needs to be fetched for query + (should be greater than or equal to frequencyInMinutes). Required. + :paramtype time_window_in_minutes: int + """ + super().__init__(**kwargs) + self.frequency_in_minutes = frequency_in_minutes + self.time_window_in_minutes = time_window_in_minutes + + +class ScopedResource(ProxyResource): + """A private link scoped resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar linked_resource_id: The resource id of the scoped Azure monitor resource. + :vartype linked_resource_id: str + :ivar provisioning_state: State of the private endpoint connection. + :vartype provisioning_state: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "linked_resource_id": {"key": "properties.linkedResourceId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, *, linked_resource_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword linked_resource_id: The resource id of the scoped Azure monitor resource. + :paramtype linked_resource_id: str + """ + super().__init__(**kwargs) + self.linked_resource_id = linked_resource_id + self.provisioning_state = None + + +class ScopedResourceListResult(_serialization.Model): + """A list of scoped resources in a private link scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.monitor.models.ScopedResource] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ScopedResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SenderAuthorization(_serialization.Model): + """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'. + + :ivar action: the permissible actions. For instance: microsoft.support/supporttickets/write. + :vartype action: str + :ivar role: the role of the user. For instance: Subscription Admin. + :vartype role: str + :ivar scope: the scope. + :vartype scope: str + """ + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "role": {"key": "role", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + } + + def __init__( + self, *, action: Optional[str] = None, role: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword action: the permissible actions. For instance: microsoft.support/supporttickets/write. + :paramtype action: str + :keyword role: the role of the user. For instance: Subscription Admin. + :paramtype role: str + :keyword scope: the scope. + :paramtype scope: str + """ + super().__init__(**kwargs) + self.action = action + self.role = role + self.scope = scope + + +class ServiceDiagnosticSettingsResource(Resource): + """Description of a service diagnostic setting. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Resource location. Required. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~azure.mgmt.monitor.models.MetricSettingsAutoGenerated] + :ivar logs: the list of logs settings. + :vartype logs: list[~azure.mgmt.monitor.models.LogSettingsAutoGenerated] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. # pylint: disable=line-too-long + :vartype workspace_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettingsAutoGenerated]"}, + "logs": {"key": "properties.logs", "type": "[LogSettingsAutoGenerated]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + storage_account_id: Optional[str] = None, + service_bus_rule_id: Optional[str] = None, + event_hub_authorization_rule_id: Optional[str] = None, + metrics: Optional[List["_models.MetricSettingsAutoGenerated"]] = None, + logs: Optional[List["_models.LogSettingsAutoGenerated"]] = None, + workspace_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Resource location. Required. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~azure.mgmt.monitor.models.MetricSettingsAutoGenerated] + :keyword logs: the list of logs settings. + :paramtype logs: list[~azure.mgmt.monitor.models.LogSettingsAutoGenerated] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. # pylint: disable=line-too-long + :paramtype workspace_id: str + """ + super().__init__(location=location, tags=tags, **kwargs) + self.storage_account_id = storage_account_id + self.service_bus_rule_id = service_bus_rule_id + self.event_hub_authorization_rule_id = event_hub_authorization_rule_id + self.metrics = metrics + self.logs = logs + self.workspace_id = workspace_id + + +class ServiceDiagnosticSettingsResourcePatch(_serialization.Model): + """Service diagnostic setting resource for patch operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~azure.mgmt.monitor.models.MetricSettingsAutoGenerated] + :ivar logs: the list of logs settings. + :vartype logs: list[~azure.mgmt.monitor.models.LogSettingsAutoGenerated] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. # pylint: disable=line-too-long + :vartype workspace_id: str + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "metrics": {"key": "properties.metrics", "type": "[MetricSettingsAutoGenerated]"}, + "logs": {"key": "properties.logs", "type": "[LogSettingsAutoGenerated]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + storage_account_id: Optional[str] = None, + service_bus_rule_id: Optional[str] = None, + event_hub_authorization_rule_id: Optional[str] = None, + metrics: Optional[List["_models.MetricSettingsAutoGenerated"]] = None, + logs: Optional[List["_models.LogSettingsAutoGenerated"]] = None, + workspace_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~azure.mgmt.monitor.models.MetricSettingsAutoGenerated] + :keyword logs: the list of logs settings. + :paramtype logs: list[~azure.mgmt.monitor.models.LogSettingsAutoGenerated] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. # pylint: disable=line-too-long + :paramtype workspace_id: str + """ + super().__init__(**kwargs) + self.tags = tags + self.storage_account_id = storage_account_id + self.service_bus_rule_id = service_bus_rule_id + self.event_hub_authorization_rule_id = event_hub_authorization_rule_id + self.metrics = metrics + self.logs = logs + self.workspace_id = workspace_id + + +class SingleBaseline(_serialization.Model): + """The baseline values for a single sensitivity value. + + All required parameters must be populated in order to send to server. + + :ivar sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", + "Medium", and "High". + :vartype sensitivity: str or ~azure.mgmt.monitor.models.BaselineSensitivity + :ivar low_thresholds: The low thresholds of the baseline. Required. + :vartype low_thresholds: list[float] + :ivar high_thresholds: The high thresholds of the baseline. Required. + :vartype high_thresholds: list[float] + """ + + _validation = { + "sensitivity": {"required": True}, + "low_thresholds": {"required": True}, + "high_thresholds": {"required": True}, + } + + _attribute_map = { + "sensitivity": {"key": "sensitivity", "type": "str"}, + "low_thresholds": {"key": "lowThresholds", "type": "[float]"}, + "high_thresholds": {"key": "highThresholds", "type": "[float]"}, + } + + def __init__( + self, + *, + sensitivity: Union[str, "_models.BaselineSensitivity"], + low_thresholds: List[float], + high_thresholds: List[float], + **kwargs: Any + ) -> None: + """ + :keyword sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", + "Medium", and "High". + :paramtype sensitivity: str or ~azure.mgmt.monitor.models.BaselineSensitivity + :keyword low_thresholds: The low thresholds of the baseline. Required. + :paramtype low_thresholds: list[float] + :keyword high_thresholds: The high thresholds of the baseline. Required. + :paramtype high_thresholds: list[float] + """ + super().__init__(**kwargs) + self.sensitivity = sensitivity + self.low_thresholds = low_thresholds + self.high_thresholds = high_thresholds + + +class SingleMetricBaseline(_serialization.Model): + """The baseline results of a single metric. + + All required parameters must be populated in order to send to server. + + :ivar id: The metric baseline Id. Required. + :vartype id: str + :ivar type: The resource type of the metric baseline resource. Required. + :vartype type: str + :ivar name: The name of the metric for which the baselines were retrieved. Required. + :vartype name: str + :ivar timespan: 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. Required. + :vartype timespan: str + :ivar interval: 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. Required. + :vartype interval: ~datetime.timedelta + :ivar namespace: The namespace of the metrics been queried. + :vartype namespace: str + :ivar baselines: The baseline for each time series that was queried. Required. + :vartype baselines: list[~azure.mgmt.monitor.models.TimeSeriesBaseline] + """ + + _validation = { + "id": {"required": True}, + "type": {"required": True}, + "name": {"required": True}, + "timespan": {"required": True}, + "interval": {"required": True}, + "baselines": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "timespan": {"key": "properties.timespan", "type": "str"}, + "interval": {"key": "properties.interval", "type": "duration"}, + "namespace": {"key": "properties.namespace", "type": "str"}, + "baselines": {"key": "properties.baselines", "type": "[TimeSeriesBaseline]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + type: str, + name: str, + timespan: str, + interval: datetime.timedelta, + baselines: List["_models.TimeSeriesBaseline"], + namespace: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The metric baseline Id. Required. + :paramtype id: str + :keyword type: The resource type of the metric baseline resource. Required. + :paramtype type: str + :keyword name: The name of the metric for which the baselines were retrieved. Required. + :paramtype name: str + :keyword timespan: 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. Required. + :paramtype timespan: str + :keyword interval: 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. Required. + :paramtype interval: ~datetime.timedelta + :keyword namespace: The namespace of the metrics been queried. + :paramtype namespace: str + :keyword baselines: The baseline for each time series that was queried. Required. + :paramtype baselines: list[~azure.mgmt.monitor.models.TimeSeriesBaseline] + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.name = name + self.timespan = timespan + self.interval = interval + self.namespace = namespace + self.baselines = baselines + + +class SinkConfiguration(_serialization.Model): + """SinkConfiguration. + + All required parameters must be populated in order to send to server. + + :ivar kind: Required. Known values are: "EventHub", "ApplicationInsights", and "LogAnalytics". + :vartype kind: str or ~azure.mgmt.monitor.models.SinkConfigurationKind + """ + + _validation = { + "kind": {"required": True}, + } + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + } + + def __init__(self, *, kind: Union[str, "_models.SinkConfigurationKind"], **kwargs: Any) -> None: + """ + :keyword kind: Required. Known values are: "EventHub", "ApplicationInsights", and + "LogAnalytics". + :paramtype kind: str or ~azure.mgmt.monitor.models.SinkConfigurationKind + """ + super().__init__(**kwargs) + self.kind = kind + + +class SmsReceiver(_serialization.Model): + """An SMS receiver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an + action group. Required. + :vartype name: str + :ivar country_code: The country code of the SMS receiver. Required. + :vartype country_code: str + :ivar phone_number: The phone number of the SMS receiver. Required. + :vartype phone_number: str + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and + "Disabled". + :vartype status: str or ~azure.mgmt.monitor.models.ReceiverStatus + """ + + _validation = { + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: + """ + :keyword name: The name of the SMS receiver. Names must be unique across all receivers within + an action group. Required. + :paramtype name: str + :keyword country_code: The country code of the SMS receiver. Required. + :paramtype country_code: str + :keyword phone_number: The phone number of the SMS receiver. Required. + :paramtype phone_number: str + """ + super().__init__(**kwargs) + self.name = name + self.country_code = country_code + self.phone_number = phone_number + self.status = None + + +class Source(_serialization.Model): + """Specifies the log search query. + + All required parameters must be populated in order to send to server. + + :ivar query: Log search query. Required for action type - AlertingAction. + :vartype query: str + :ivar authorized_resources: List of Resource referred into query. + :vartype authorized_resources: list[str] + :ivar data_source_id: The resource uri over which log search query is to be run. Required. + :vartype data_source_id: str + :ivar query_type: Set value to 'ResultCount' . "ResultCount" + :vartype query_type: str or ~azure.mgmt.monitor.models.QueryType + """ + + _validation = { + "data_source_id": {"required": True}, + } + + _attribute_map = { + "query": {"key": "query", "type": "str"}, + "authorized_resources": {"key": "authorizedResources", "type": "[str]"}, + "data_source_id": {"key": "dataSourceId", "type": "str"}, + "query_type": {"key": "queryType", "type": "str"}, + } + + def __init__( + self, + *, + data_source_id: str, + query: Optional[str] = None, + authorized_resources: Optional[List[str]] = None, + query_type: Optional[Union[str, "_models.QueryType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword query: Log search query. Required for action type - AlertingAction. + :paramtype query: str + :keyword authorized_resources: List of Resource referred into query. + :paramtype authorized_resources: list[str] + :keyword data_source_id: The resource uri over which log search query is to be run. Required. + :paramtype data_source_id: str + :keyword query_type: Set value to 'ResultCount' . "ResultCount" + :paramtype query_type: str or ~azure.mgmt.monitor.models.QueryType + """ + super().__init__(**kwargs) + self.query = query + self.authorized_resources = authorized_resources + self.data_source_id = data_source_id + self.query_type = query_type + + +class SubscriptionProxyOnlyResource(_serialization.Model): + """A proxy only azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Location of the resource. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword location: Location of the resource. + :paramtype location: str + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + + +class SubscriptionDiagnosticSettingsResource(SubscriptionProxyOnlyResource): + """The subscription diagnostic setting resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Location of the resource. + :vartype location: str + :ivar storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + maintain backwards compatibility. + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: list[~azure.mgmt.monitor.models.SubscriptionLogSettings] + :ivar workspace_id: 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. # pylint: disable=line-too-long + :vartype workspace_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, + "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, + "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, + "logs": {"key": "properties.logs", "type": "[SubscriptionLogSettings]"}, + "workspace_id": {"key": "properties.workspaceId", "type": "str"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + storage_account_id: Optional[str] = None, + service_bus_rule_id: Optional[str] = None, + event_hub_authorization_rule_id: Optional[str] = None, + event_hub_name: Optional[str] = None, + logs: Optional[List["_models.SubscriptionLogSettings"]] = None, + workspace_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: Location of the resource. + :paramtype location: str + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: list[~azure.mgmt.monitor.models.SubscriptionLogSettings] + :keyword workspace_id: 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. # pylint: disable=line-too-long + :paramtype workspace_id: str + """ + super().__init__(location=location, **kwargs) + self.storage_account_id = storage_account_id + self.service_bus_rule_id = service_bus_rule_id + self.event_hub_authorization_rule_id = event_hub_authorization_rule_id + self.event_hub_name = event_hub_name + self.logs = logs + self.workspace_id = workspace_id + + +class SubscriptionDiagnosticSettingsResourceCollection(_serialization.Model): # pylint: disable=name-too-long + """Represents a collection of subscription diagnostic settings resources. + + :ivar value: The collection of subscription diagnostic settings resources. + :vartype value: list[~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[SubscriptionDiagnosticSettingsResource]"}, + } + + def __init__( + self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The collection of subscription diagnostic settings resources. + :paramtype value: list[~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource] + """ + super().__init__(**kwargs) + self.value = value + + +class SubscriptionLogSettings(_serialization.Model): + """Part of Subscription diagnostic setting. Specifies the settings for a particular log. + + All required parameters must be populated in order to send to server. + + :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting + is applied to. + :vartype category: str + :ivar enabled: a value indicating whether this log is enabled. Required. + :vartype enabled: bool + """ + + _validation = { + "enabled": {"required": True}, + } + + _attribute_map = { + "category": {"key": "category", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: bool, category: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword category: Name of a Subscription Diagnostic Log category for a resource type this + setting is applied to. + :paramtype category: str + :keyword enabled: a value indicating whether this log is enabled. Required. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.category = category + self.enabled = enabled + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.monitor.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.monitor.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.monitor.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TagsResource(_serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags on a + PrivateLinkScope instance. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TestNotificationDetailsResponse(_serialization.Model): + """The details of the test notification results. + + All required parameters must be populated in order to send to server. + + :ivar context: The context info. + :vartype context: ~azure.mgmt.monitor.models.Context + :ivar state: The overall state. Required. + :vartype state: str + :ivar completed_time: The completed time. + :vartype completed_time: str + :ivar created_time: The created time. + :vartype created_time: str + :ivar action_details: The list of action detail. + :vartype action_details: list[~azure.mgmt.monitor.models.ActionDetail] + """ + + _validation = { + "state": {"required": True}, + } + + _attribute_map = { + "context": {"key": "context", "type": "Context"}, + "state": {"key": "state", "type": "str"}, + "completed_time": {"key": "completedTime", "type": "str"}, + "created_time": {"key": "createdTime", "type": "str"}, + "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, + } + + def __init__( + self, + *, + state: str, + context: Optional["_models.Context"] = None, + completed_time: Optional[str] = None, + created_time: Optional[str] = None, + action_details: Optional[List["_models.ActionDetail"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword context: The context info. + :paramtype context: ~azure.mgmt.monitor.models.Context + :keyword state: The overall state. Required. + :paramtype state: str + :keyword completed_time: The completed time. + :paramtype completed_time: str + :keyword created_time: The created time. + :paramtype created_time: str + :keyword action_details: The list of action detail. + :paramtype action_details: list[~azure.mgmt.monitor.models.ActionDetail] + """ + super().__init__(**kwargs) + self.context = context + self.state = state + self.completed_time = completed_time + self.created_time = created_time + self.action_details = action_details + + +class TimeSeriesBaseline(_serialization.Model): + """The baseline values for a single time series. + + All required parameters must be populated in order to send to server. + + :ivar aggregation: The aggregation type of the metric. Required. + :vartype aggregation: str + :ivar dimensions: The dimensions of this time series. + :vartype dimensions: list[~azure.mgmt.monitor.models.MetricSingleDimension] + :ivar timestamps: The list of timestamps of the baselines. Required. + :vartype timestamps: list[~datetime.datetime] + :ivar data: The baseline values for each sensitivity. Required. + :vartype data: list[~azure.mgmt.monitor.models.SingleBaseline] + :ivar metadata_values: The baseline metadata values. + :vartype metadata_values: list[~azure.mgmt.monitor.models.BaselineMetadata] + """ + + _validation = { + "aggregation": {"required": True}, + "timestamps": {"required": True}, + "data": {"required": True}, + } + + _attribute_map = { + "aggregation": {"key": "aggregation", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricSingleDimension]"}, + "timestamps": {"key": "timestamps", "type": "[iso-8601]"}, + "data": {"key": "data", "type": "[SingleBaseline]"}, + "metadata_values": {"key": "metadataValues", "type": "[BaselineMetadata]"}, + } + + def __init__( + self, + *, + aggregation: str, + timestamps: List[datetime.datetime], + data: List["_models.SingleBaseline"], + dimensions: Optional[List["_models.MetricSingleDimension"]] = None, + metadata_values: Optional[List["_models.BaselineMetadata"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword aggregation: The aggregation type of the metric. Required. + :paramtype aggregation: str + :keyword dimensions: The dimensions of this time series. + :paramtype dimensions: list[~azure.mgmt.monitor.models.MetricSingleDimension] + :keyword timestamps: The list of timestamps of the baselines. Required. + :paramtype timestamps: list[~datetime.datetime] + :keyword data: The baseline values for each sensitivity. Required. + :paramtype data: list[~azure.mgmt.monitor.models.SingleBaseline] + :keyword metadata_values: The baseline metadata values. + :paramtype metadata_values: list[~azure.mgmt.monitor.models.BaselineMetadata] + """ + super().__init__(**kwargs) + self.aggregation = aggregation + self.dimensions = dimensions + self.timestamps = timestamps + self.data = data + self.metadata_values = metadata_values + + +class TimeSeriesElement(_serialization.Model): + """A time series result type. The discriminator value is always TimeSeries in this case. + + :ivar metadatavalues: The metadata values returned if $filter was specified in the call. + :vartype metadatavalues: list[~azure.mgmt.monitor.models.MetadataValue] + :ivar data: An array of data points representing the metric values. This is only returned if a + result type of data is specified. + :vartype data: list[~azure.mgmt.monitor.models.MetricValue] + """ + + _attribute_map = { + "metadatavalues": {"key": "metadatavalues", "type": "[MetadataValue]"}, + "data": {"key": "data", "type": "[MetricValue]"}, + } + + def __init__( + self, + *, + metadatavalues: Optional[List["_models.MetadataValue"]] = None, + data: Optional[List["_models.MetricValue"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword metadatavalues: The metadata values returned if $filter was specified in the call. + :paramtype metadatavalues: list[~azure.mgmt.monitor.models.MetadataValue] + :keyword data: An array of data points representing the metric values. This is only returned + if a result type of data is specified. + :paramtype data: list[~azure.mgmt.monitor.models.MetricValue] + """ + super().__init__(**kwargs) + self.metadatavalues = metadatavalues + self.data = data + + +class TimeWindow(_serialization.Model): + """A specific date-time for the profile. + + All required parameters must be populated in order to send to server. + + :ivar time_zone: 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. + :vartype time_zone: str + :ivar start: the start time for the profile in ISO 8601 format. Required. + :vartype start: ~datetime.datetime + :ivar end: the end time for the profile in ISO 8601 format. Required. + :vartype end: ~datetime.datetime + """ + + _validation = { + "start": {"required": True}, + "end": {"required": True}, + } + + _attribute_map = { + "time_zone": {"key": "timeZone", "type": "str"}, + "start": {"key": "start", "type": "iso-8601"}, + "end": {"key": "end", "type": "iso-8601"}, + } + + def __init__( + self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword time_zone: 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. + :paramtype time_zone: str + :keyword start: the start time for the profile in ISO 8601 format. Required. + :paramtype start: ~datetime.datetime + :keyword end: the end time for the profile in ISO 8601 format. Required. + :paramtype end: ~datetime.datetime + """ + super().__init__(**kwargs) + self.time_zone = time_zone + self.start = start + self.end = end + + +class TriggerCondition(_serialization.Model): + """The condition that results in the Log Search rule. + + All required parameters must be populated in order to send to server. + + :ivar threshold_operator: Evaluation operation for rule - 'GreaterThan' or 'LessThan. Known + values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", and "Equal". + :vartype threshold_operator: str or ~azure.mgmt.monitor.models.ConditionalOperator + :ivar threshold: Result or count threshold based on which rule should be triggered. Required. + :vartype threshold: float + :ivar metric_trigger: Trigger condition for metric query rule. + :vartype metric_trigger: ~azure.mgmt.monitor.models.LogMetricTrigger + """ + + _validation = { + "threshold_operator": {"required": True}, + "threshold": {"required": True}, + } + + _attribute_map = { + "threshold_operator": {"key": "thresholdOperator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "metric_trigger": {"key": "metricTrigger", "type": "LogMetricTrigger"}, + } + + def __init__( + self, + *, + threshold_operator: Union[str, "_models.ConditionalOperator"] = "GreaterThanOrEqual", + threshold: float, + metric_trigger: Optional["_models.LogMetricTrigger"] = None, + **kwargs: Any + ) -> None: + """ + :keyword threshold_operator: Evaluation operation for rule - 'GreaterThan' or 'LessThan. Known + values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", and "Equal". + :paramtype threshold_operator: str or ~azure.mgmt.monitor.models.ConditionalOperator + :keyword threshold: Result or count threshold based on which rule should be triggered. + Required. + :paramtype threshold: float + :keyword metric_trigger: Trigger condition for metric query rule. + :paramtype metric_trigger: ~azure.mgmt.monitor.models.LogMetricTrigger + """ + super().__init__(**kwargs) + self.threshold_operator = threshold_operator + self.threshold = threshold + self.metric_trigger = metric_trigger + + +class VMInsightsOnboardingStatus(ProxyResource): + """VM Insights onboarding status for a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar resource_id: Azure Resource Manager identifier of the resource whose onboarding status is + being represented. + :vartype resource_id: str + :ivar onboarding_status: The onboarding status for the resource. Note that, a higher level + scope, e.g., resource group or subscription, is considered onboarded if at least one resource + under it is onboarded. Known values are: "onboarded", "notOnboarded", and "unknown". + :vartype onboarding_status: str or ~azure.mgmt.monitor.models.OnboardingStatus + :ivar data_status: The status of VM Insights data from the resource. When reported as + ``present`` the data array will contain information about the data containers to which data for + the specified resource is being routed. Known values are: "present" and "notPresent". + :vartype data_status: str or ~azure.mgmt.monitor.models.DataStatus + :ivar data: Containers that currently store VM Insights data for the specified resource. + :vartype data: list[~azure.mgmt.monitor.models.DataContainer] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "onboarding_status": {"key": "properties.onboardingStatus", "type": "str"}, + "data_status": {"key": "properties.dataStatus", "type": "str"}, + "data": {"key": "properties.data", "type": "[DataContainer]"}, + } + + def __init__( + self, + *, + resource_id: Optional[str] = None, + onboarding_status: Optional[Union[str, "_models.OnboardingStatus"]] = None, + data_status: Optional[Union[str, "_models.DataStatus"]] = None, + data: Optional[List["_models.DataContainer"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource_id: Azure Resource Manager identifier of the resource whose onboarding status + is being represented. + :paramtype resource_id: str + :keyword onboarding_status: The onboarding status for the resource. Note that, a higher level + scope, e.g., resource group or subscription, is considered onboarded if at least one resource + under it is onboarded. Known values are: "onboarded", "notOnboarded", and "unknown". + :paramtype onboarding_status: str or ~azure.mgmt.monitor.models.OnboardingStatus + :keyword data_status: The status of VM Insights data from the resource. When reported as + ``present`` the data array will contain information about the data containers to which data for + the specified resource is being routed. Known values are: "present" and "notPresent". + :paramtype data_status: str or ~azure.mgmt.monitor.models.DataStatus + :keyword data: Containers that currently store VM Insights data for the specified resource. + :paramtype data: list[~azure.mgmt.monitor.models.DataContainer] + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.onboarding_status = onboarding_status + self.data_status = data_status + self.data = data + + +class VoiceReceiver(_serialization.Model): + """A voice receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the voice receiver. Names must be unique across all receivers within an + action group. Required. + :vartype name: str + :ivar country_code: The country code of the voice receiver. Required. + :vartype country_code: str + :ivar phone_number: The phone number of the voice receiver. Required. + :vartype phone_number: str + """ + + _validation = { + "name": {"required": True}, + "country_code": {"required": True}, + "phone_number": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "country_code": {"key": "countryCode", "type": "str"}, + "phone_number": {"key": "phoneNumber", "type": "str"}, + } + + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: + """ + :keyword name: The name of the voice receiver. Names must be unique across all receivers within + an action group. Required. + :paramtype name: str + :keyword country_code: The country code of the voice receiver. Required. + :paramtype country_code: str + :keyword phone_number: The phone number of the voice receiver. Required. + :paramtype phone_number: str + """ + super().__init__(**kwargs) + self.name = name + self.country_code = country_code + self.phone_number = phone_number + + +class WebhookNotification(_serialization.Model): + """Webhook notification of an autoscale event. + + :ivar service_uri: the service address to receive the notification. + :vartype service_uri: str + :ivar properties: a property bag of settings. This value can be empty. + :vartype properties: dict[str, str] + """ + + _attribute_map = { + "service_uri": {"key": "serviceUri", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, + } + + def __init__( + self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: + """ + :keyword service_uri: the service address to receive the notification. + :paramtype service_uri: str + :keyword properties: a property bag of settings. This value can be empty. + :paramtype properties: dict[str, str] + """ + super().__init__(**kwargs) + self.service_uri = service_uri + self.properties = properties + + +class WebhookReceiver(_serialization.Model): + """A webhook receiver. + + All required parameters must be populated in order to send to server. + + :ivar name: The name of the webhook receiver. Names must be unique across all receivers within + an action group. Required. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. Required. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar use_aad_auth: Indicates whether or not use AAD authentication. + :vartype use_aad_auth: bool + :ivar object_id: Indicates the webhook app object Id for aad auth. + :vartype object_id: str + :ivar identifier_uri: Indicates the identifier uri for aad auth. + :vartype identifier_uri: str + :ivar tenant_id: Indicates the tenant id for aad auth. + :vartype tenant_id: str + """ + + _validation = { + "name": {"required": True}, + "service_uri": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "service_uri": {"key": "serviceUri", "type": "str"}, + "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, + "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, + "object_id": {"key": "objectId", "type": "str"}, + "identifier_uri": {"key": "identifierUri", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + service_uri: str, + use_common_alert_schema: bool = False, + use_aad_auth: bool = False, + object_id: Optional[str] = None, + identifier_uri: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the webhook receiver. Names must be unique across all receivers + within an action group. Required. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. Required. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword use_aad_auth: Indicates whether or not use AAD authentication. + :paramtype use_aad_auth: bool + :keyword object_id: Indicates the webhook app object Id for aad auth. + :paramtype object_id: str + :keyword identifier_uri: Indicates the identifier uri for aad auth. + :paramtype identifier_uri: str + :keyword tenant_id: Indicates the tenant id for aad auth. + :paramtype tenant_id: str + """ + super().__init__(**kwargs) + self.name = name + self.service_uri = service_uri + self.use_common_alert_schema = use_common_alert_schema + self.use_aad_auth = use_aad_auth + self.object_id = object_id + self.identifier_uri = identifier_uri + self.tenant_id = tenant_id + + +class WebtestLocationAvailabilityCriteria(MetricAlertCriteria): + """Specifies the metric alert rule criteria for a web test resource. + + All required parameters must be populated in order to send to server. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, JSON] + :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". + :vartype odata_type: str or ~azure.mgmt.monitor.models.Odatatype + :ivar web_test_id: The Application Insights web test Id. Required. + :vartype web_test_id: str + :ivar component_id: The Application Insights resource Id. Required. + :vartype component_id: str + :ivar failed_location_count: The number of failed locations. Required. + :vartype failed_location_count: float + """ + + _validation = { + "odata_type": {"required": True}, + "web_test_id": {"required": True}, + "component_id": {"required": True}, + "failed_location_count": {"required": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "odata_type": {"key": "odata\\.type", "type": "str"}, + "web_test_id": {"key": "webTestId", "type": "str"}, + "component_id": {"key": "componentId", "type": "str"}, + "failed_location_count": {"key": "failedLocationCount", "type": "float"}, + } + + def __init__( + self, + *, + web_test_id: str, + component_id: str, + failed_location_count: float, + additional_properties: Optional[Dict[str, JSON]] = None, + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, JSON] + :keyword web_test_id: The Application Insights web test Id. Required. + :paramtype web_test_id: str + :keyword component_id: The Application Insights resource Id. Required. + :paramtype component_id: str + :keyword failed_location_count: The number of failed locations. Required. + :paramtype failed_location_count: float + """ + super().__init__(additional_properties=additional_properties, **kwargs) + self.odata_type: str = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" + self.web_test_id = web_test_id + self.component_id = component_id + self.failed_location_count = failed_location_count + + +class WorkspaceInfo(_serialization.Model): + """Information about a Log Analytics Workspace. + + All required parameters must be populated in order to send to server. + + :ivar id: Azure Resource Manager identifier of the Log Analytics Workspace. Required. + :vartype id: str + :ivar location: Location of the Log Analytics workspace. Required. + :vartype location: str + :ivar customer_id: Log Analytics workspace identifier. Required. + :vartype customer_id: str + """ + + _validation = { + "id": {"required": True}, + "location": {"required": True}, + "customer_id": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "customer_id": {"key": "properties.customerId", "type": "str"}, + } + + def __init__( + self, *, id: str, location: str, customer_id: str, **kwargs: Any # pylint: disable=redefined-builtin + ) -> None: + """ + :keyword id: Azure Resource Manager identifier of the Log Analytics Workspace. Required. + :paramtype id: str + :keyword location: Location of the Log Analytics workspace. Required. + :paramtype location: str + :keyword customer_id: Log Analytics workspace identifier. Required. + :paramtype customer_id: str + """ + super().__init__(**kwargs) + self.id = id + self.location = location + self.customer_id = customer_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_monitor_management_client_enums.py new file mode 100644 index 0000000000000..2593cb152f7da --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_monitor_management_client_enums.py @@ -0,0 +1,345 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the aggregation type of the metric.""" + + NONE = "None" + AVERAGE = "Average" + COUNT = "Count" + MINIMUM = "Minimum" + MAXIMUM = "Maximum" + TOTAL = "Total" + + +class AggregationTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the criteria time aggregation types.""" + + AVERAGE = "Average" + COUNT = "Count" + MINIMUM = "Minimum" + MAXIMUM = "Maximum" + TOTAL = "Total" + + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity Level of Alert.""" + + ZERO = "0" + ONE = "1" + TWO = "2" + THREE = "3" + FOUR = "4" + + +class BaselineSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the sensitivity of the baseline.""" + + LOW = "Low" + MEDIUM = "Medium" + HIGH = "High" + + +class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the diagnostic settings category.""" + + METRICS = "Metrics" + LOGS = "Logs" + + +class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the operator that is used to compare the metric data and the threshold.""" + + EQUALS = "Equals" + NOT_EQUALS = "NotEquals" + GREATER_THAN = "GreaterThan" + GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + LESS_THAN = "LessThan" + LESS_THAN_OR_EQUAL = "LessThanOrEqual" + + +class ConditionalOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result Condition Evaluation criteria.""" + + GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + LESS_THAN_OR_EQUAL = "LessThanOrEqual" + GREATER_THAN = "GreaterThan" + LESS_THAN = "LessThan" + EQUAL = "Equal" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class CriterionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the type of threshold criteria.""" + + STATIC_THRESHOLD_CRITERION = "StaticThresholdCriterion" + DYNAMIC_THRESHOLD_CRITERION = "DynamicThresholdCriterion" + + +class DataSourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Datasource kind.""" + + PERFORMANCE_COUNTER = "PerformanceCounter" + ETW_PROVIDERS = "ETWProviders" + WINDOWS_EVENT_LOGS = "WindowsEventLogs" + + +class DataStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of VM Insights data from the resource. When reported as ``present`` the data array + will contain information about the data containers to which data for the specified resource is + being routed. + """ + + PRESENT = "present" + NOT_PRESENT = "notPresent" + + +class DynamicThresholdOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operator used to compare the metric value against the threshold.""" + + GREATER_THAN = "GreaterThan" + LESS_THAN = "LessThan" + GREATER_OR_LESS_THAN = "GreaterOrLessThan" + + +class DynamicThresholdSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The extent of deviation required to trigger an alert. This will affect how tight the threshold + is to the metric series pattern. + """ + + LOW = "Low" + MEDIUM = "Medium" + HIGH = "High" + + +class Enabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The flag which indicates whether the Log Search rule is enabled. Value should be true or false.""" + + TRUE = "true" + FALSE = "false" + + +class EventLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the event level.""" + + CRITICAL = "Critical" + ERROR = "Error" + WARNING = "Warning" + INFORMATIONAL = "Informational" + VERBOSE = "Verbose" + + +class GuestDiagnosticSettingsOsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Operating system type for the configuration.""" + + WINDOWS = "Windows" + LINUX = "Linux" + + +class MetricClass(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The class of the metric.""" + + AVAILABILITY = "Availability" + TRANSACTIONS = "Transactions" + ERRORS = "Errors" + LATENCY = "Latency" + SATURATION = "Saturation" + + +class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the metric statistic type. How the metrics from multiple instances are combined.""" + + AVERAGE = "Average" + MIN = "Min" + MAX = "Max" + SUM = "Sum" + COUNT = "Count" + + +class MetricTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric Trigger Evaluation Type.""" + + CONSECUTIVE = "Consecutive" + TOTAL = "Total" + + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of the metric.""" + + COUNT = "Count" + BYTES = "Bytes" + SECONDS = "Seconds" + COUNT_PER_SECOND = "CountPerSecond" + BYTES_PER_SECOND = "BytesPerSecond" + PERCENT = "Percent" + MILLI_SECONDS = "MilliSeconds" + BYTE_SECONDS = "ByteSeconds" + UNSPECIFIED = "Unspecified" + CORES = "Cores" + MILLI_CORES = "MilliCores" + NANO_CORES = "NanoCores" + BITS_PER_SECOND = "BitsPerSecond" + + +class NamespaceClassification(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Kind of namespace.""" + + PLATFORM = "Platform" + CUSTOM = "Custom" + QOS = "Qos" + + +class Odatatype(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """specifies the type of the alert criteria.""" + + MICROSOFT_AZURE_MONITOR_SINGLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = ( + "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" + ) + MICROSOFT_AZURE_MONITOR_MULTIPLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = ( + "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + ) + MICROSOFT_AZURE_MONITOR_WEBTEST_LOCATION_AVAILABILITY_CRITERIA = ( + "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" + ) + + +class OnboardingStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The onboarding status for the resource. Note that, a higher level scope, e.g., resource group + or subscription, is considered onboarded if at least one resource under it is onboarded. + """ + + ONBOARDED = "onboarded" + NOT_ONBOARDED = "notOnboarded" + UNKNOWN = "unknown" + + +class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the criteria operator.""" + + EQUALS = "Equals" + GREATER_THAN = "GreaterThan" + GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + LESS_THAN = "LessThan" + LESS_THAN_OR_EQUAL = "LessThanOrEqual" + INCLUDE = "Include" + + +class PredictiveAutoscalePolicyScaleMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the predictive autoscale mode.""" + + DISABLED = "Disabled" + FORECAST_ONLY = "ForecastOnly" + ENABLED = "Enabled" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the scheduled query rule.""" + + SUCCEEDED = "Succeeded" + DEPLOYING = "Deploying" + CANCELED = "Canceled" + FAILED = "Failed" + + +class QueryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Set value to 'ResultAccount'.""" + + RESULT_COUNT = "ResultCount" + + +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the status of the receiver. Receivers that are not Enabled will not receive any + communications. + """ + + NOT_SPECIFIED = "NotSpecified" + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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. + """ + + NONE = "None" + SECOND = "Second" + MINUTE = "Minute" + HOUR = "Hour" + DAY = "Day" + WEEK = "Week" + MONTH = "Month" + YEAR = "Year" + + +class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ResultType.""" + + DATA = "Data" + METADATA = "Metadata" + + +class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the scale direction. Whether the scaling action increases or decreases the number of instances.""" + + NONE = "None" + INCREASE = "Increase" + DECREASE = "Decrease" + + +class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """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. + """ + + EQUALS = "Equals" + NOT_EQUALS = "NotEquals" + + +class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """the type of action that should occur when the scale rule fires.""" + + CHANGE_COUNT = "ChangeCount" + PERCENT_CHANGE_COUNT = "PercentChangeCount" + EXACT_COUNT = "ExactCount" + SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" + + +class SinkConfigurationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SinkConfigurationKind.""" + + EVENT_HUB = "EventHub" + APPLICATION_INSIGHTS = "ApplicationInsights" + LOG_ANALYTICS = "LogAnalytics" + + +class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """time aggregation type. How the data that is collected should be combined over time. The default + value is Average. + """ + + AVERAGE = "Average" + MINIMUM = "Minimum" + MAXIMUM = "Maximum" + TOTAL = "Total" + COUNT = "Count" + LAST = "Last" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_patch.py new file mode 100644 index 0000000000000..914c0139611e8 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models/_patch.py @@ -0,0 +1,47 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +# the enum is already deprecated, but we keep it for CLI compatibility +class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Operators allowed in the rule condition.""" + + GREATER_THAN = "GreaterThan" + GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + LESS_THAN = "LessThan" + LESS_THAN_OR_EQUAL = "LessThanOrEqual" + + +# the enum is already deprecated, but we keep it for CLI compatibility +class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Aggregation operators allowed in a rule.""" + + AVERAGE = "Average" + MINIMUM = "Minimum" + MAXIMUM = "Maximum" + TOTAL = "Total" + LAST = "Last" + + +__all__: List[str] = [ + "ConditionOperator", + "TimeAggregationOperator", +] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/__init__.py new file mode 100644 index 0000000000000..11574f0dde871 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/__init__.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._action_groups_operations import ActionGroupsOperations # type: ignore +from ._activity_log_alerts_operations import ActivityLogAlertsOperations # type: ignore +from ._activity_logs_operations import ActivityLogsOperations # type: ignore +from ._tenant_activity_logs_operations import TenantActivityLogsOperations # type: ignore +from ._alert_rule_incidents_operations import AlertRuleIncidentsOperations # type: ignore +from ._autoscale_settings_operations import AutoscaleSettingsOperations # type: ignore +from ._predictive_metric_operations import PredictiveMetricOperations # type: ignore +from ._baselines_operations import BaselinesOperations # type: ignore +from ._diagnostic_settings_operations import DiagnosticSettingsOperations # type: ignore +from ._diagnostic_settings_category_operations import DiagnosticSettingsCategoryOperations # type: ignore +from ._event_categories_operations import EventCategoriesOperations # type: ignore +from ._guest_diagnostics_settings_operations import GuestDiagnosticsSettingsOperations # type: ignore +from ._guest_diagnostics_settings_association_operations import GuestDiagnosticsSettingsAssociationOperations # type: ignore +from ._log_profiles_operations import LogProfilesOperations # type: ignore +from ._metric_alerts_operations import MetricAlertsOperations # type: ignore +from ._metric_alerts_status_operations import MetricAlertsStatusOperations # type: ignore +from ._metric_definitions_operations import MetricDefinitionsOperations # type: ignore +from ._metric_namespaces_operations import MetricNamespacesOperations # type: ignore +from ._metrics_operations import MetricsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations # type: ignore +from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations # type: ignore +from ._vm_insights_operations import VMInsightsOperations # type: ignore +from ._private_link_scopes_operations import PrivateLinkScopesOperations # type: ignore +from ._private_link_scope_operation_status_operations import PrivateLinkScopeOperationStatusOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations # type: ignore +from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ActionGroupsOperations", + "ActivityLogAlertsOperations", + "ActivityLogsOperations", + "TenantActivityLogsOperations", + "AlertRuleIncidentsOperations", + "AutoscaleSettingsOperations", + "PredictiveMetricOperations", + "BaselinesOperations", + "DiagnosticSettingsOperations", + "DiagnosticSettingsCategoryOperations", + "EventCategoriesOperations", + "GuestDiagnosticsSettingsOperations", + "GuestDiagnosticsSettingsAssociationOperations", + "LogProfilesOperations", + "MetricAlertsOperations", + "MetricAlertsStatusOperations", + "MetricDefinitionsOperations", + "MetricNamespacesOperations", + "MetricsOperations", + "Operations", + "ScheduledQueryRulesOperations", + "ServiceDiagnosticSettingsOperations", + "VMInsightsOperations", + "PrivateLinkScopesOperations", + "PrivateLinkScopeOperationStatusOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkScopedResourcesOperations", + "SubscriptionDiagnosticSettingsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_action_groups_operations.py new file mode 100644 index 0000000000000..761c871381429 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_action_groups_operations.py @@ -0,0 +1,1858 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_notifications_at_resource_group_level_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_test_notifications_request(notification_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_test_notifications_at_resource_group_level_request( # pylint: disable=name-too-long + resource_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_test_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long + resource_group_name: str, action_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_enable_receiver_request( + resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`action_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: _models.ActionGroupResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: ~azure.mgmt.monitor.models.ActionGroupResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Required. + :type action_group: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: Union[_models.ActionGroupResource, IO[bytes]], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO[bytes] type. Required. + :type action_group: ~azure.mgmt.monitor.models.ActionGroupResource or IO[bytes] + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group, (IOBase, bytes)): + _content = action_group + else: + _json = self._serialize.body(action_group, "ActionGroupResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActionGroupResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: + """Get an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActionGroupResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, action_group_name: str, **kwargs: Any + ) -> None: + """Delete an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: _models.ActionGroupPatchBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: ~azure.mgmt.monitor.models.ActionGroupPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Required. + :type action_group_patch: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: Union[_models.ActionGroupPatchBody, IO[bytes]], + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO[bytes] type. Required. + :type action_group_patch: ~azure.mgmt.monitor.models.ActionGroupPatchBody or IO[bytes] + :return: ActionGroupResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActionGroupResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(action_group_patch, (IOBase, bytes)): + _content = action_group_patch + else: + _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") + + _request = build_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActionGroupResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _post_test_notifications_initial( + self, notification_request: Union[_models.NotificationRequestBody, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IOBase, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") + + _request = build_post_test_notifications_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_post_test_notifications( + self, + notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_post_test_notifications( + self, notification_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_post_test_notifications( + self, notification_request: Union[_models.NotificationRequestBody, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + Is either a NotificationRequestBody type or a IO[bytes] type. Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody or IO[bytes] + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._post_test_notifications_initial( + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.TestNotificationDetailsResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.TestNotificationDetailsResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IOBase, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") + + _request = build_create_notifications_at_resource_group_level_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a NotificationRequestBody type or a IO[bytes] type. Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody or IO[bytes] + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_notifications_at_resource_group_level_initial( + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.TestNotificationDetailsResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.TestNotificationDetailsResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notification_request, (IOBase, bytes)): + _content = notification_request + else: + _json = self._serialize.body(notification_request, "NotificationRequestBody") + + _request = build_create_notifications_at_action_group_resource_level_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Required. + :type notification_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, + resource_group_name: str, + action_group_name: str, + notification_request: Union[_models.NotificationRequestBody, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + Is either a NotificationRequestBody type or a IO[bytes] type. Required. + :type notification_request: ~azure.mgmt.monitor.models.NotificationRequestBody or IO[bytes] + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.TestNotificationDetailsResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_notifications_at_action_group_resource_level_initial( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.TestNotificationDetailsResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.TestNotificationDetailsResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param notification_id: The notification id. Required. + :type notification_id: str + :return: TestNotificationDetailsResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.TestNotificationDetailsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + + _request = build_get_test_notifications_request( + notification_id=notification_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long + self, resource_group_name: str, notification_id: str, **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param notification_id: The notification id. Required. + :type notification_id: str + :return: TestNotificationDetailsResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.TestNotificationDetailsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + + _request = build_get_test_notifications_at_resource_group_level_request( + resource_group_name=resource_group_name, + notification_id=notification_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long + self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param notification_id: The notification id. Required. + :type notification_id: str + :return: TestNotificationDetailsResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.TestNotificationDetailsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + + _request = build_get_test_notifications_at_action_group_resource_level_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_id=notification_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: + """Get a list of all action groups in a subscription. + + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActionGroupResource"]: + """Get a list of all action groups in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ActionGroupResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.ActionGroupResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def enable_receiver( + self, + resource_group_name: str, + action_group_name: str, + enable_request: _models.EnableRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_request: ~azure.mgmt.monitor.models.EnableRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def enable_receiver( + self, + resource_group_name: str, + action_group_name: str, + enable_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Required. + :type enable_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: Union[_models.EnableRequest, IO[bytes]], + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param action_group_name: The name of the action group. Required. + :type action_group_name: str + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO[bytes] + type. Required. + :type enable_request: ~azure.mgmt.monitor.models.EnableRequest or IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(enable_request, (IOBase, bytes)): + _content = enable_request + else: + _json = self._serialize.body(enable_request, "EnableRequest") + + _request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_activity_log_alerts_operations.py new file mode 100644 index 0000000000000..b4f0101b02d9e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_activity_log_alerts_operations.py @@ -0,0 +1,764 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ActivityLogAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: _models.ActivityLogAlertResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Required. + :type activity_log_alert: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: Union[_models.ActivityLogAlertResource, IO[bytes]], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Create a new activity log alert or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert: The activity log alert to create or use for the update. Is either a + ActivityLogAlertResource type or a IO[bytes] type. Required. + :type activity_log_alert: ~azure.mgmt.monitor.models.ActivityLogAlertResource or IO[bytes] + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert, (IOBase, bytes)): + _content = activity_log_alert + else: + _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Get an activity log alert. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any + ) -> None: + """Delete an activity log alert. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: _models.ActivityLogAlertPatchBody, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: ~azure.mgmt.monitor.models.ActivityLogAlertPatchBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Required. + :type activity_log_alert_patch: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: Union[_models.ActivityLogAlertPatchBody, IO[bytes]], + **kwargs: Any + ) -> _models.ActivityLogAlertResource: + """Updates an existing ActivityLogAlertResource's tags. To update other fields use the + CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param activity_log_alert_name: The name of the activity log alert. Required. + :type activity_log_alert_name: str + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a + ActivityLogAlertPatchBody type or a IO[bytes] type. Required. + :type activity_log_alert_patch: ~azure.mgmt.monitor.models.ActivityLogAlertPatchBody or + IO[bytes] + :return: ActivityLogAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ActivityLogAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(activity_log_alert_patch, (IOBase, bytes)): + _content = activity_log_alert_patch + else: + _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertPatchBody") + + _request = build_update_request( + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: + """Get a list of all activity log alerts in a subscription. + + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ActivityLogAlertResource"]: + """Get a list of all activity log alerts in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either ActivityLogAlertResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.ActivityLogAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_activity_logs_operations.py new file mode 100644 index 0000000000000..da1047a8866d8 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_activity_logs_operations.py @@ -0,0 +1,178 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + subscription_id: str, *, filter: str, select: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ActivityLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`activity_logs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> Iterable["_models.EventData"]: + """Provides the list of records from the activity logs. + + :param filter: Reduces the set of data collected.\\ :code:`
`This argument is required and + it also requires at least the start date/time.\\ :code:`
`The **$filter** argument is very + restricted and allows only the following patterns.\\ :code:`
`- *List events for a resource + group*\\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.\\ :code:`
`- + *List events for resource*\\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and + eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.\\ + :code:`
`- *List events for a subscription in a time range*\\ : $filter=eventTimestamp ge + '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'.\\ + :code:`
`- *List events for a resource provider*\\ : $filter=eventTimestamp ge + '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and + resourceProvider eq 'resourceProviderName'.\\ :code:`
`- *List events for a correlation + Id*\\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'.\\ :code:`
`\\ + :code:`
`\\ **NOTE**\\ : No other syntax is allowed. Required. + :type filter: str + :param select: Used to fetch events with only the given properties.\\ :code:`
`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*. Default value is None. + :type select: str + :return: An iterator like instance of either EventData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + select=select, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventDataCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_alert_rule_incidents_operations.py new file mode 100644 index 0000000000000..9bb3b51c0c133 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_alert_rule_incidents_operations.py @@ -0,0 +1,255 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, rule_name: str, incident_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "incidentName": _SERIALIZER.url("incident_name", incident_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_alert_rule_request( + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AlertRuleIncidentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`alert_rule_incidents` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, rule_name: str, incident_name: str, **kwargs: Any) -> _models.Incident: + """Gets an incident associated to an alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param incident_name: The name of the incident to retrieve. Required. + :type incident_name: str + :return: Incident or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.Incident + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.Incident] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + incident_name=incident_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Incident", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_alert_rule( + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> Iterable["_models.Incident"]: + """Gets a list of incidents associated to an alert rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: An iterator like instance of either Incident or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.Incident] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.IncidentListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_alert_rule_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IncidentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_autoscale_settings_operations.py new file mode 100644 index 0000000000000..0c7046d0e4c5f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_autoscale_settings_operations.py @@ -0,0 +1,764 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AutoscaleSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`autoscale_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AutoscaleSettingResource"]: + """Lists the autoscale settings for a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: _models.AutoscaleSettingResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + autoscale_setting_name: str, + parameters: Union[_models.AutoscaleSettingResource, IO[bytes]], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Creates or updates an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.AutoscaleSettingResource or IO[bytes] + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleSettingResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any + ) -> None: + """Deletes and autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Gets an autoscale setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: ~azure.mgmt.monitor.models.AutoscaleSettingResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Required. + :type autoscale_setting_resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.AutoscaleSettingResource: + """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO[bytes] type. Required. + :type autoscale_setting_resource: ~azure.mgmt.monitor.models.AutoscaleSettingResourcePatch or + IO[bytes] + :return: AutoscaleSettingResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AutoscaleSettingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(autoscale_setting_resource, (IOBase, bytes)): + _content = autoscale_setting_resource + else: + _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: + """Lists the autoscale settings for a subscription. + + :return: An iterator like instance of either AutoscaleSettingResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.AutoscaleSettingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_baselines_operations.py new file mode 100644 index 0000000000000..90581a8a31fcd --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_baselines_operations.py @@ -0,0 +1,231 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import datetime +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_uri: str, + *, + metricnames: Optional[str] = None, + metricnamespace: Optional[str] = None, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, _models.ResultType]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricBaselines") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if metricnames is not None: + _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") + if metricnamespace is not None: + _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") + if timespan is not None: + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") + if interval is not None: + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") + if aggregation is not None: + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") + if sensitivities is not None: + _params["sensitivities"] = _SERIALIZER.query("sensitivities", sensitivities, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if result_type is not None: + _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BaselinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`baselines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_uri: str, + metricnames: Optional[str] = None, + metricnamespace: Optional[str] = None, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, _models.ResultType]] = None, + **kwargs: Any + ) -> Iterable["_models.SingleMetricBaseline"]: + """**Lists the metric baseline values for a resource**. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param metricnames: 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'**. Default value is None. + :type metricnames: str + :param metricnamespace: Metric namespace that contains the requested metric names. Default + value is None. + :type metricnamespace: str + :param timespan: The timespan of the query. It is a string with the following format + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. + :type timespan: str + :param interval: The interval (i.e. timegrain) of the query. Default value is None. + :type interval: ~datetime.timedelta + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. + :type aggregation: str + :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is + None. + :type sensitivities: str + :param filter: 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' "**. Default value is None. + :type filter: str + :param result_type: Allows retrieving only metadata of the baseline. On data request all + information is retrieved. Known values are: "Data" and "Metadata". Default value is None. + :type result_type: str or ~azure.mgmt.monitor.models.ResultType + :return: An iterator like instance of either SingleMetricBaseline or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.SingleMetricBaseline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + metricnames=metricnames, + metricnamespace=metricnamespace, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + filter=filter, + result_type=result_type, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_diagnostic_settings_category_operations.py new file mode 100644 index 0000000000000..9a15ed4b6967f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_diagnostic_settings_category_operations.py @@ -0,0 +1,212 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DiagnosticSettingsCategoryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`diagnostic_settings_category` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: + """Gets the diagnostic settings category for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: DiagnosticSettingsCategoryResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsCategoryResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: + """Lists the diagnostic settings categories for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: DiagnosticSettingsCategoryResourceCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsCategoryResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "DiagnosticSettingsCategoryResourceCollection", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..356321ca281c6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_diagnostic_settings_operations.py @@ -0,0 +1,460 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`diagnostic_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: + """Gets the active diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_uri: str, + name: str, + parameters: _models.DiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_uri: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_uri: str, + name: str, + parameters: Union[_models.DiagnosticSettingsResource, IO[bytes]], + **kwargs: Any + ) -> _models.DiagnosticSettingsResource: + """Creates or updates diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.DiagnosticSettingsResource or IO[bytes] + :return: DiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.DiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DiagnosticSettingsResource") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_uri: str, name: str, **kwargs: Any + ) -> None: + """Deletes existing diagnostic settings for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_uri=resource_uri, + name=name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.DiagnosticSettingsResource"]: + """Gets the active diagnostic settings list for the specified resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: An iterator like instance of either DiagnosticSettingsResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.DiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_event_categories_operations.py new file mode 100644 index 0000000000000..5bef421d35d75 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_event_categories_operations.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventcategories") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class EventCategoriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`event_categories` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.LocalizableString"]: + """Get the list of available event categories supported in the Activity Logs Service.\\ + :code:`
`The current list includes the following: Administrative, Security, ServiceHealth, + Alert, Recommendation, Policy. + + :return: An iterator like instance of either LocalizableString or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.LocalizableString] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventCategoryCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventCategoryCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_guest_diagnostics_settings_association_operations.py new file mode 100644 index 0000000000000..45c9a27c07b5b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_guest_diagnostics_settings_association_operations.py @@ -0,0 +1,750 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GuestDiagnosticsSettingsAssociationOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings_association` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: + ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Required. + :type diagnostic_settings_association: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_uri: str, + association_name: str, + diagnostic_settings_association: Union[_models.GuestDiagnosticSettingsAssociationResource, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Creates or updates guest diagnostics settings association. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param diagnostic_settings_association: The diagnostic settings association to create or + update. Is either a GuestDiagnosticSettingsAssociationResource type or a IO[bytes] type. + Required. + :type diagnostic_settings_association: + ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource or IO[bytes] + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings_association, (IOBase, bytes)): + _content = diagnostic_settings_association + else: + _json = self._serialize.body(diagnostic_settings_association, "GuestDiagnosticSettingsAssociationResource") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_uri: str, association_name: str, **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Gets guest diagnostics association settings. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_uri: str, association_name: str, **kwargs: Any + ) -> None: + """Delete guest diagnostics association settings. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def update( + self, + resource_uri: str, + association_name: str, + parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_uri: str, + association_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_uri: str, + association_name: str, + parameters: Union[_models.GuestDiagnosticSettingsAssociationResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsAssociationResource: + """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use + the CreateOrUpdate method. + + :param resource_uri: The fully qualified ID of the resource, including the resource name and + resource type. Required. + :type resource_uri: str + :param association_name: The name of the diagnostic settings association. Required. + :type association_name: str + :param parameters: Parameters supplied to the operation. Is either a + GuestDiagnosticSettingsAssociationResourcePatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResourcePatch or + IO[bytes] + :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsAssociationResourcePatch") + + _request = build_update_request( + resource_uri=resource_uri, + association_name=association_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsAssociationResource"]: + """Get a list of all guest diagnostic settings association in a subscription. + + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.GuestDiagnosticSettingsAssociationResource"]: + """Get a list of all guest diagnostic settings association in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsAssociationResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_guest_diagnostics_settings_operations.py new file mode 100644 index 0000000000000..747e968ecdbac --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_guest_diagnostics_settings_operations.py @@ -0,0 +1,765 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GuestDiagnosticsSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: _models.GuestDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Required. + :type diagnostic_settings: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Required. + :type diagnostic_settings: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: Union[_models.GuestDiagnosticSettingsResource, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Creates or updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param diagnostic_settings: The configuration to create or update. Is either a + GuestDiagnosticSettingsResource type or a IO[bytes] type. Required. + :type diagnostic_settings: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource or + IO[bytes] + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_settings, (IOBase, bytes)): + _content = diagnostic_settings + else: + _json = self._serialize.body(diagnostic_settings, "GuestDiagnosticSettingsResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Gets guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: _models.GuestDiagnosticSettingsPatchResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsPatchResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + diagnostic_settings_name: str, + parameters: Union[_models.GuestDiagnosticSettingsPatchResource, IO[bytes]], + **kwargs: Any + ) -> _models.GuestDiagnosticSettingsResource: + """Updates guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :param parameters: The configuration to patch. Is either a GuestDiagnosticSettingsPatchResource + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsPatchResource or IO[bytes] + :return: GuestDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GuestDiagnosticSettingsPatchResource") + + _request = build_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any + ) -> None: + """Delete guest diagnostics settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param diagnostic_settings_name: The name of the diagnostic setting. Required. + :type diagnostic_settings_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsResource"]: + """Get a list of all guest diagnostic settings in a subscription. + + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.GuestDiagnosticSettingsResource"]: + """Get a list of all guest diagnostic settings in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.GuestDiagnosticSettingsResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_log_profiles_operations.py new file mode 100644 index 0000000000000..d7da72c221038 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_log_profiles_operations.py @@ -0,0 +1,579 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_delete_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_get_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class LogProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`log_profiles` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def delete(self, log_profile_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Deletes the log profile. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: + """Gets the log profile. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) + + _request = build_get_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogProfileResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + log_profile_name: str, + parameters: _models.LogProfileResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.LogProfileResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, log_profile_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, log_profile_name: str, parameters: Union[_models.LogProfileResource, IO[bytes]], **kwargs: Any + ) -> _models.LogProfileResource: + """Create or update a log profile in Azure Monitoring REST API. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param parameters: Parameters supplied to the operation. Is either a LogProfileResource type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.LogProfileResource or IO[bytes] + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogProfileResource") + + _request = build_create_or_update_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogProfileResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + log_profile_name: str, + log_profiles_resource: _models.LogProfileResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Required. + :type log_profiles_resource: ~azure.mgmt.monitor.models.LogProfileResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + log_profile_name: str, + log_profiles_resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Required. + :type log_profiles_resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + log_profile_name: str, + log_profiles_resource: Union[_models.LogProfileResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.LogProfileResource: + """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. + + :param log_profile_name: The name of the log profile. Required. + :type log_profile_name: str + :param log_profiles_resource: Parameters supplied to the operation. Is either a + LogProfileResourcePatch type or a IO[bytes] type. Required. + :type log_profiles_resource: ~azure.mgmt.monitor.models.LogProfileResourcePatch or IO[bytes] + :return: LogProfileResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogProfileResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(log_profiles_resource, (IOBase, bytes)): + _content = log_profiles_resource + else: + _json = self._serialize.body(log_profiles_resource, "LogProfileResourcePatch") + + _request = build_update_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogProfileResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.LogProfileResource"]: + """List the log profiles. + + :return: An iterator like instance of either LogProfileResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.LogProfileResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LogProfileCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_alerts_operations.py new file mode 100644 index 0000000000000..f0bc1a0a1457a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_alerts_operations.py @@ -0,0 +1,750 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class MetricAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`metric_alerts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.MetricAlertResource"]: + """Retrieve alert rule definitions in a subscription. + + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.MetricAlertResource"]: + """Retrieve alert rule definitions in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either MetricAlertResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.MetricAlertResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: + """Retrieve an alert rule definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.MetricAlertResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResource, IO[bytes]], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Create or update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a + MetricAlertResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResource or IO[bytes] + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.MetricAlertResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.MetricAlertResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.MetricAlertResource: + """Update an metric alert definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a MetricAlertResourcePatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.MetricAlertResourcePatch or IO[bytes] + :return: MetricAlertResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MetricAlertResourcePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> None: + """Delete an alert rule definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_alerts_status_operations.py new file mode 100644 index 0000000000000..623bf307d86cc --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_alerts_status_operations.py @@ -0,0 +1,238 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_name_request( + resource_group_name: str, rule_name: str, status_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "statusName": _SERIALIZER.url("status_name", status_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MetricAlertsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`metric_alerts_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertStatusCollection: + """Retrieve an alert rule status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: MetricAlertStatusCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertStatusCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_name( + self, resource_group_name: str, rule_name: str, status_name: str, **kwargs: Any + ) -> _models.MetricAlertStatusCollection: + """Retrieve an alert rule status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param status_name: The name of the status. Required. + :type status_name: str + :return: MetricAlertStatusCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.MetricAlertStatusCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) + + _request = build_list_by_name_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + status_name=status_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_definitions_operations.py new file mode 100644 index 0000000000000..d6fbeb0b748f8 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_definitions_operations.py @@ -0,0 +1,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_uri: str, *, metricnamespace: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if metricnamespace is not None: + _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MetricDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MetricDefinition"]: + """Lists the metric definitions for the resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. + :type metricnamespace: str + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + metricnamespace=metricnamespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_namespaces_operations.py new file mode 100644 index 0000000000000..4620933afcfe3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metric_namespaces_operations.py @@ -0,0 +1,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_uri: str, *, start_time: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricNamespaces") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if start_time is not None: + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MetricNamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`metric_namespaces` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_uri: str, start_time: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MetricNamespace"]: + """Lists the metric namespaces for the resource. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param start_time: The ISO 8601 conform Date start time from which to query for metric + namespaces. Default value is None. + :type start_time: str + :return: An iterator like instance of either MetricNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.MetricNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) + cls: ClsType[_models.MetricNamespaceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + start_time=start_time, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metrics_operations.py new file mode 100644 index 0000000000000..13c7d6e4cefd4 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_metrics_operations.py @@ -0,0 +1,228 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_uri: str, + *, + timespan: Optional[str] = None, + interval: Optional[str] = None, + metricnames: Optional[str] = None, + aggregation: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, _models.ResultType]] = None, + metricnamespace: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metrics") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if timespan is not None: + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") + if interval is not None: + _params["interval"] = _SERIALIZER.query("interval", interval, "str") + if metricnames is not None: + _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") + if aggregation is not None: + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + if orderby is not None: + _params["orderby"] = _SERIALIZER.query("orderby", orderby, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if result_type is not None: + _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if metricnamespace is not None: + _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MetricsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`metrics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_uri: str, + timespan: Optional[str] = None, + interval: Optional[str] = None, + metricnames: Optional[str] = None, + aggregation: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, _models.ResultType]] = None, + metricnamespace: Optional[str] = None, + **kwargs: Any + ) -> _models.Response: + """**Lists the metric values for a resource**. This API uses the `default ARM throttling limits + `_. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param timespan: The timespan of the query. It is a string with the following format + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. + :type timespan: str + :param interval: The interval (i.e. timegrain) of the query in ISO 8601 duration format. + Defaults to PT1M. Special case for 'FULL' value that returns single datapoint for entire time + span requested. + *Examples: PT15M, PT1H, P1D, FULL*. Default value is None. + :type interval: str + :param metricnames: The names of the metrics (comma separated) to retrieve. Limit 20 metrics. + Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: + 'Metric,Name1' should be **'Metric%2Name1'**. Default value is None. + :type metricnames: str + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. + :type aggregation: str + :param top: The maximum number of records to retrieve. + Valid only if $filter is specified. + Defaults to 10. Default value is None. + :type top: int + :param orderby: The aggregation to use for sorting results and the direction of the sort. + Only one order can be specified. + Examples: sum asc. Default value is None. + :type orderby: str + :param filter: 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' "**. Default value is None. + :type filter: str + :param result_type: Reduces the set of data collected. The syntax allowed depends on the + operation. See the operation's description for details. Known values are: "Data" and + "Metadata". Default value is None. + :type result_type: str or ~azure.mgmt.monitor.models.ResultType + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. + :type metricnamespace: str + :return: Response or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.Response + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.Response] = kwargs.pop("cls", None) + + _request = build_list_request( + resource_uri=resource_uri, + timespan=timespan, + interval=interval, + metricnames=metricnames, + aggregation=aggregation, + top=top, + orderby=orderby, + filter=filter, + result_type=result_type, + metricnamespace=metricnamespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Response", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_operations.py new file mode 100644 index 0000000000000..e9472e6fc565c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_operations.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> _models.OperationListResult: + """Lists all of the available operations from Microsoft.Insights provider. + + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.OperationListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_patch.py similarity index 100% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_patch.py diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_predictive_metric_operations.py new file mode 100644 index 0000000000000..acacab0e09ff3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_predictive_metric_operations.py @@ -0,0 +1,188 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import datetime +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + autoscale_setting_name: str, + subscription_id: str, + *, + timespan: str, + interval: datetime.timedelta, + metric_namespace: str, + metric_name: str, + aggregation: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") + _params["metricNamespace"] = _SERIALIZER.query("metric_namespace", metric_namespace, "str") + _params["metricName"] = _SERIALIZER.query("metric_name", metric_name, "str") + _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PredictiveMetricOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`predictive_metric` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + autoscale_setting_name: str, + timespan: str, + interval: datetime.timedelta, + metric_namespace: str, + metric_name: str, + aggregation: str, + **kwargs: Any + ) -> _models.PredictiveResponse: + """get predictive autoscale metric future data. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param autoscale_setting_name: The autoscale setting name. Required. + :type autoscale_setting_name: str + :param timespan: The timespan of the query. It is a string with the following format + 'startDateTime_ISO/endDateTime_ISO'. Required. + :type timespan: str + :param interval: The interval (i.e. timegrain) of the query. Required. + :type interval: ~datetime.timedelta + :param metric_namespace: Metric namespace to query metric definitions for. Required. + :type metric_namespace: str + :param metric_name: 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'**. Required. + :type metric_name: str + :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. + :type aggregation: str + :return: PredictiveResponse or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.PredictiveResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + timespan=timespan, + interval=interval, + metric_namespace=metric_namespace, + metric_name=metric_name, + aggregation=aggregation, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PredictiveResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_endpoint_connections_operations.py new file mode 100644 index 0000000000000..26eaacb2f0e58 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,657 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_list_by_private_link_scope_request( + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.monitor.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.PrivateEndpointConnection or IO[bytes] + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """Gets all private endpoint connections on a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_resources_operations.py new file mode 100644 index 0000000000000..5b3a84abcd800 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_resources_operations.py @@ -0,0 +1,256 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_private_link_scope_request( + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, scope_name: str, group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scope_operation_status_operations.py new file mode 100644 index 0000000000000..ea0578e3e668a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scope_operation_status_operations.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + async_operation_id: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkScopeOperationStatusOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`private_link_scope_operation_status` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: + """Get the status of an azure asynchronous operation associated with a private link scope + operation. + + :param async_operation_id: The operation Id. Required. + :type async_operation_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: OperationStatus or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.OperationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) + + _request = build_get_request( + async_operation_id=async_operation_id, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scoped_resources_operations.py new file mode 100644 index 0000000000000..9051cd2b3bd04 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scoped_resources_operations.py @@ -0,0 +1,632 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_list_by_private_link_scope_request( + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkScopedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`private_link_scoped_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: + """Gets a scoped resource in a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :return: ScopedResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ScopedResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScopedResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: Union[_models.ScopedResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScopedResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: _models.ScopedResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.monitor.models.ScopedResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + scope_name: str, + name: str, + parameters: Union[_models.ScopedResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ScopedResource]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :param parameters: Is either a ScopedResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.ScopedResource or IO[bytes] + :return: An instance of LROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ScopedResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ScopedResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ScopedResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param name: The name of the scoped resource object. Required. + :type name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_private_link_scope( + self, resource_group_name: str, scope_name: str, **kwargs: Any + ) -> Iterable["_models.ScopedResource"]: + """Gets all private endpoint connections on a private link scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An iterator like instance of either ScopedResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.ScopedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_private_link_scope_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scopes_operations.py new file mode 100644 index 0000000000000..10afda7150b0f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_private_link_scopes_operations.py @@ -0,0 +1,807 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_get_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_tags_request( + resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`private_link_scopes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: + """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: + """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _delete_initial(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + scope_name=scope_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _models.AzureMonitorPrivateLinkScope: + """Returns a Azure Monitor PrivateLinkScope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Required. + :type azure_monitor_private_link_scope_payload: + ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Required. + :type azure_monitor_private_link_scope_payload: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO[bytes]], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different + value for InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create + or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a + IO[bytes] type. Required. + :type azure_monitor_private_link_scope_payload: + ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope or IO[bytes] + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_monitor_private_link_scope_payload, (IOBase, bytes)): + _content = azure_monitor_private_link_scope_payload + else: + _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: ~azure.mgmt.monitor.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Required. + :type private_link_scope_tags: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + scope_name: str, + private_link_scope_tags: Union[_models.TagsResource, IO[bytes]], + **kwargs: Any + ) -> _models.AzureMonitorPrivateLinkScope: + """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate + method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. + :type scope_name: str + :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope + instance. Is either a TagsResource type or a IO[bytes] type. Required. + :type private_link_scope_tags: ~azure.mgmt.monitor.models.TagsResource or IO[bytes] + :return: AzureMonitorPrivateLinkScope or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.AzureMonitorPrivateLinkScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_scope_tags, (IOBase, bytes)): + _content = private_link_scope_tags + else: + _json = self._serialize.body(private_link_scope_tags, "TagsResource") + + _request = build_update_tags_request( + resource_group_name=resource_group_name, + scope_name=scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_scheduled_query_rules_operations.py new file mode 100644 index 0000000000000..349f83a477c80 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_scheduled_query_rules_operations.py @@ -0,0 +1,772 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request( + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request( + resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScheduledQueryRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.LogSearchRuleResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResource, IO[bytes]], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Creates or updates an log search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a + LogSearchRuleResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResource or IO[bytes] + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: + """Gets an Log Search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.LogSearchRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.LogSearchRuleResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.LogSearchRuleResource: + """Update log search Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a LogSearchRuleResourcePatch + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResourcePatch or IO[bytes] + :return: LogSearchRuleResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "LogSearchRuleResourcePatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LogSearchRuleResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> None: + """Deletes a Log Search rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_subscription( + self, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.LogSearchRuleResource"]: + """List the Log Search rules within a subscription group. + + :param filter: The filter to apply on the operation. For more information please see + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. + :type filter: str + :return: An iterator like instance of either LogSearchRuleResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.LogSearchRuleResource"]: + """List the Log Search rules within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For more information please see + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. + :type filter: str + :return: An iterator like instance of either LogSearchRuleResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.LogSearchRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_service_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..bc195b45a455c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_service_diagnostic_settings_operations.py @@ -0,0 +1,420 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServiceDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`service_diagnostic_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: + """Gets the active diagnostic settings for the specified resource. **WARNING**\\ : This method + will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_uri: str, + parameters: _models.ServiceDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\\ : This + method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, resource_uri: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\\ : This + method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO[bytes]], **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Create or update new diagnostic settings for the specified resource. **WARNING**\\ : This + method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param parameters: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource or IO[bytes] + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. + :type service_diagnostic_settings_resource: + ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. + :type service_diagnostic_settings_resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_uri: str, + service_diagnostic_settings_resource: Union[_models.ServiceDiagnosticSettingsResourcePatch, IO[bytes]], + **kwargs: Any + ) -> _models.ServiceDiagnosticSettingsResource: + """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the + CreateOrUpdate method. **WARNING**\\ : This method will be deprecated in future releases. + + :param resource_uri: The identifier of the resource. Required. + :type resource_uri: str + :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResourcePatch type or a IO[bytes] type. Required. + :type service_diagnostic_settings_resource: + ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResourcePatch or IO[bytes] + :return: ServiceDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.ServiceDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(service_diagnostic_settings_resource, (IOBase, bytes)): + _content = service_diagnostic_settings_resource + else: + _json = self._serialize.body(service_diagnostic_settings_resource, "ServiceDiagnosticSettingsResourcePatch") + + _request = build_update_request( + resource_uri=resource_uri, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_subscription_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..9b81f58f573eb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_subscription_diagnostic_settings_operations.py @@ -0,0 +1,427 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SubscriptionDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`subscription_diagnostic_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: + """Gets the active subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) + + _request = build_get_request( + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + name: str, + parameters: _models.SubscriptionDiagnosticSettingsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO[bytes]], **kwargs: Any + ) -> _models.SubscriptionDiagnosticSettingsResource: + """Creates or updates subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :param parameters: Parameters supplied to the operation. Is either a + SubscriptionDiagnosticSettingsResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource or + IO[bytes] + :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") + + _request = build_create_or_update_request( + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Deletes existing subscription diagnostic settings for the specified resource. + + :param name: The name of the diagnostic setting. Required. + :type name: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: + """Gets the active subscription diagnostic settings list for the specified subscriptionId. + + :return: SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.SubscriptionDiagnosticSettingsResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) + + _request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize( + "SubscriptionDiagnosticSettingsResourceCollection", pipeline_response.http_response + ) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_tenant_activity_logs_operations.py new file mode 100644 index 0000000000000..a6784437a9f92 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_tenant_activity_logs_operations.py @@ -0,0 +1,176 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(*, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventtypes/management/values") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TenantActivityLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`tenant_activity_logs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.EventData"]: + """Gets the Activity Logs for the Tenant.\\ :code:`
`Everything that is applicable to the API + to get the Activity Logs for the subscription is applicable to this API (the parameters, + $filter, etc.).\\ :code:`
`One thing to point out here is that this API does *not* retrieve + the logs at the individual subscription of the tenant but only surfaces the logs that were + generated at the tenant level. + + :param filter: Reduces the set of data collected. :code:`
`The **$filter** is very + restricted and allows only the following patterns.\\ :code:`
`- List events for a resource + group: $filter=eventTimestamp ge '\\ :code:``' and eventTimestamp le '\\ + :code:``' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '\\ + :code:``'.\\ :code:`
`- List events for resource: $filter=eventTimestamp + ge '\\ :code:``' and eventTimestamp le '\\ :code:``' and eventChannels eq + 'Admin, Operation' and resourceUri eq '\\ :code:``'.\\ :code:`
`- List events + for a subscription: $filter=eventTimestamp ge '\\ :code:``' and eventTimestamp le + '\\ :code:``' and eventChannels eq 'Admin, Operation'.\\ :code:`
`- List events + for a resource provider: $filter=eventTimestamp ge '\\ :code:``' and eventTimestamp + le '\\ :code:``' and eventChannels eq 'Admin, Operation' and resourceProvider eq '\\ + :code:``'.\\ :code:`
`- List events for a correlation Id: + api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and + eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and + correlationId eq '\\ :code:``'.\\ :code:`
`\\ **NOTE**\\ : No other syntax is + allowed. Default value is None. + :type filter: str + :param select: Used to fetch events with only the given properties.\\ :code:`
`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*. Default value is None. + :type select: str + :return: An iterator like instance of either EventData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.models.EventData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + filter=filter, + select=select, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventDataCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_vm_insights_operations.py new file mode 100644 index 0000000000000..fde3c9121d45e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/operations/_vm_insights_operations.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_onboarding_status_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" + ) + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VMInsightsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.monitor.MonitorManagementClient`'s + :attr:`vm_insights` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMInsightsOnboardingStatus: + """Retrieves the VM Insights onboarding status for the specified resource or resource scope. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or + scope, whose status to retrieve. Required. + :type resource_uri: str + :return: VMInsightsOnboardingStatus or the result of cls(response) + :rtype: ~azure.mgmt.monitor.models.VMInsightsOnboardingStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) + cls: ClsType[_models.VMInsightsOnboardingStatus] = kwargs.pop("cls", None) + + _request = build_get_onboarding_status_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("VMInsightsOnboardingStatus", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py deleted file mode 100644 index 84225ab1970a1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json deleted file mode 100644 index 977b6fa088403..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2015-04-01", - "total_api_version_list": ["2014-04-01", "2015-04-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "activity_logs": "ActivityLogsOperations", - "autoscale_settings": "AutoscaleSettingsOperations", - "event_categories": "EventCategoriesOperations", - "operations": "Operations", - "tenant_activity_logs": "TenantActivityLogsOperations", - "alert_rules": "AlertRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py deleted file mode 100644 index 1c618b18af391..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - ActivityLogsOperations, - AlertRulesOperations, - AutoscaleSettingsOperations, - EventCategoriesOperations, - Operations, - TenantActivityLogsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar activity_logs: ActivityLogsOperations operations - :vartype activity_logs: azure.mgmt.monitor.v2015_04_01.operations.ActivityLogsOperations - :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: - azure.mgmt.monitor.v2015_04_01.operations.AutoscaleSettingsOperations - :ivar event_categories: EventCategoriesOperations operations - :vartype event_categories: azure.mgmt.monitor.v2015_04_01.operations.EventCategoriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.monitor.v2015_04_01.operations.Operations - :ivar tenant_activity_logs: TenantActivityLogsOperations operations - :vartype tenant_activity_logs: - azure.mgmt.monitor.v2015_04_01.operations.TenantActivityLogsOperations - :ivar alert_rules: AlertRulesOperations operations - :vartype alert_rules: azure.mgmt.monitor.v2015_04_01.operations.AlertRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.event_categories = EventCategoriesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.tenant_activity_logs = TenantActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py deleted file mode 100644 index ff77a05cbd874..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py deleted file mode 100644 index 5640ee5665058..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - ActivityLogsOperations, - AlertRulesOperations, - AutoscaleSettingsOperations, - EventCategoriesOperations, - Operations, - TenantActivityLogsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar activity_logs: ActivityLogsOperations operations - :vartype activity_logs: azure.mgmt.monitor.v2015_04_01.aio.operations.ActivityLogsOperations - :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: - azure.mgmt.monitor.v2015_04_01.aio.operations.AutoscaleSettingsOperations - :ivar event_categories: EventCategoriesOperations operations - :vartype event_categories: - azure.mgmt.monitor.v2015_04_01.aio.operations.EventCategoriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.monitor.v2015_04_01.aio.operations.Operations - :ivar tenant_activity_logs: TenantActivityLogsOperations operations - :vartype tenant_activity_logs: - azure.mgmt.monitor.v2015_04_01.aio.operations.TenantActivityLogsOperations - :ivar alert_rules: AlertRulesOperations operations - :vartype alert_rules: azure.mgmt.monitor.v2015_04_01.aio.operations.AlertRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.event_categories = EventCategoriesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.tenant_activity_logs = TenantActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py deleted file mode 100644 index c3fc4cfffbbea..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._activity_logs_operations import ActivityLogsOperations -from ._autoscale_settings_operations import AutoscaleSettingsOperations -from ._event_categories_operations import EventCategoriesOperations -from ._operations import Operations -from ._tenant_activity_logs_operations import TenantActivityLogsOperations -from ._alert_rules_operations import AlertRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivityLogsOperations", - "AutoscaleSettingsOperations", - "EventCategoriesOperations", - "Operations", - "TenantActivityLogsOperations", - "AlertRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py deleted file mode 100644 index 696f55a089d13..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py +++ /dev/null @@ -1,149 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._activity_logs_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActivityLogsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.aio.MonitorManagementClient`'s - :attr:`activity_logs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.EventData"]: - """Provides the list of records from the activity logs. - - :param filter: Reduces the set of data collected.:code:`
`This argument is required and it - also requires at least the start date/time.:code:`
`The **$filter** argument is very - restricted and allows only the following patterns.:code:`
`- *List events for a resource - group*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.:code:`
`- *List - events for resource*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and - eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.:code:`
`- - *List events for a subscription in a time range*\ : $filter=eventTimestamp ge - '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - '2014-07-20T04:36:37.6407898Z'.:code:`
`- *List events for a resource provider*\ : - $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.:code:`
`- - *List events for a correlation Id*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' - and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq - 'correlationID'.:code:`
`:code:`
`\ **NOTE**\ : No other syntax is allowed. Required. - :type filter: str - :param select: Used to fetch events with only the given properties.:code:`
`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*. Default - value is None. - :type select: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventData or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_04_01.models.EventData] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EventDataCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py deleted file mode 100644 index ab65fc45afc36..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py +++ /dev/null @@ -1,627 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._alert_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AlertRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.aio.MonitorManagementClient`'s - :attr:`alert_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.AlertRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - AlertRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AlertRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: - """Gets a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a - AlertRuleResourcePatch type or a IO type. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_rules_resource, (IO, bytes)): - _content = alert_rules_resource - else: - _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py deleted file mode 100644 index c16d1484744b3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py +++ /dev/null @@ -1,635 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._autoscale_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoscaleSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.aio.MonitorManagementClient`'s - :attr:`autoscale_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: _models.AutoscaleSettingResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: Union[_models.AutoscaleSettingResource, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AutoscaleSettingResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> None: - """Deletes and autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Gets an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @overload - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a - AutoscaleSettingResourcePatch type or a IO type. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(autoscale_setting_resource, (IO, bytes)): - _content = autoscale_setting_resource - else: - _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py deleted file mode 100644 index a27a3ce7c584f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py +++ /dev/null @@ -1,124 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._event_categories_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class EventCategoriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.aio.MonitorManagementClient`'s - :attr:`event_categories` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.LocalizableString"]: - """Get the list of available event categories supported in the Activity Logs - Service.:code:`
`The current list includes the following: Administrative, Security, - ServiceHealth, Alert, Recommendation, Policy. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocalizableString or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_04_01.models.LocalizableString] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.EventCategoryCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EventCategoryCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py deleted file mode 100644 index c3ab3e4bac0d2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py +++ /dev/null @@ -1,103 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.aio.MonitorManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.OperationListResult: - """Lists all of the available operations from Microsoft.Insights provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.OperationListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py deleted file mode 100644 index 0a4609b6cb5e3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py +++ /dev/null @@ -1,155 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._tenant_activity_logs_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TenantActivityLogsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.aio.MonitorManagementClient`'s - :attr:`tenant_activity_logs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventData"]: - """Gets the Activity Logs for the Tenant.:code:`
`Everything that is applicable to the API to - get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, - etc.).:code:`
`One thing to point out here is that this API does *not* retrieve the logs at - the individual subscription of the tenant but only surfaces the logs that were generated at the - tenant level. - - :param filter: Reduces the set of data collected. :code:`
`The **$filter** is very - restricted and allows only the following patterns.:code:`
`- List events for a resource - group: $filter=eventTimestamp ge ':code:``' and eventTimestamp le ':code:``' and eventChannels eq 'Admin, Operation' and resourceGroupName eq - ':code:``'.:code:`
`- List events for resource: $filter=eventTimestamp ge - ':code:``' and eventTimestamp le ':code:``' and eventChannels eq 'Admin, - Operation' and resourceUri eq ':code:``'.:code:`
`- List events for a - subscription: $filter=eventTimestamp ge ':code:``' and eventTimestamp le - ':code:``' and eventChannels eq 'Admin, Operation'.:code:`
`- List events for a - resource provider: $filter=eventTimestamp ge ':code:``' and eventTimestamp le - ':code:``' and eventChannels eq 'Admin, Operation' and resourceProvider eq - ':code:``'.:code:`
`- List events for a correlation Id: - api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and - eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - correlationId eq ':code:``'.:code:`
`\ **NOTE**\ : No other syntax is - allowed. Default value is None. - :type filter: str - :param select: Used to fetch events with only the given properties.:code:`
`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*. Default - value is None. - :type select: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventData or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_04_01.models.EventData] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - select=select, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EventDataCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py deleted file mode 100644 index 3b949b4fe53ac..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AlertRuleResource -from ._models_py3 import AlertRuleResourceCollection -from ._models_py3 import AlertRuleResourcePatch -from ._models_py3 import AutoscaleNotification -from ._models_py3 import AutoscaleProfile -from ._models_py3 import AutoscaleSettingResource -from ._models_py3 import AutoscaleSettingResourceCollection -from ._models_py3 import AutoscaleSettingResourcePatch -from ._models_py3 import EmailNotification -from ._models_py3 import ErrorResponse -from ._models_py3 import EventCategoryCollection -from ._models_py3 import EventData -from ._models_py3 import EventDataCollection -from ._models_py3 import HttpRequestInfo -from ._models_py3 import LocalizableString -from ._models_py3 import LocationThresholdRuleCondition -from ._models_py3 import ManagementEventAggregationCondition -from ._models_py3 import ManagementEventRuleCondition -from ._models_py3 import MetricTrigger -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Recurrence -from ._models_py3 import RecurrentSchedule -from ._models_py3 import Resource -from ._models_py3 import RuleAction -from ._models_py3 import RuleCondition -from ._models_py3 import RuleDataSource -from ._models_py3 import RuleEmailAction -from ._models_py3 import RuleManagementEventClaimsDataSource -from ._models_py3 import RuleManagementEventDataSource -from ._models_py3 import RuleMetricDataSource -from ._models_py3 import RuleWebhookAction -from ._models_py3 import ScaleAction -from ._models_py3 import ScaleCapacity -from ._models_py3 import ScaleRule -from ._models_py3 import ScaleRuleMetricDimension -from ._models_py3 import SenderAuthorization -from ._models_py3 import ThresholdRuleCondition -from ._models_py3 import TimeWindow -from ._models_py3 import WebhookNotification - -from ._monitor_management_client_enums import ComparisonOperationType -from ._monitor_management_client_enums import ConditionOperator -from ._monitor_management_client_enums import EventLevel -from ._monitor_management_client_enums import MetricStatisticType -from ._monitor_management_client_enums import RecurrenceFrequency -from ._monitor_management_client_enums import ScaleDirection -from ._monitor_management_client_enums import ScaleRuleMetricDimensionOperationType -from ._monitor_management_client_enums import ScaleType -from ._monitor_management_client_enums import TimeAggregationOperator -from ._monitor_management_client_enums import TimeAggregationType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertRuleResource", - "AlertRuleResourceCollection", - "AlertRuleResourcePatch", - "AutoscaleNotification", - "AutoscaleProfile", - "AutoscaleSettingResource", - "AutoscaleSettingResourceCollection", - "AutoscaleSettingResourcePatch", - "EmailNotification", - "ErrorResponse", - "EventCategoryCollection", - "EventData", - "EventDataCollection", - "HttpRequestInfo", - "LocalizableString", - "LocationThresholdRuleCondition", - "ManagementEventAggregationCondition", - "ManagementEventRuleCondition", - "MetricTrigger", - "Operation", - "OperationDisplay", - "OperationListResult", - "Recurrence", - "RecurrentSchedule", - "Resource", - "RuleAction", - "RuleCondition", - "RuleDataSource", - "RuleEmailAction", - "RuleManagementEventClaimsDataSource", - "RuleManagementEventDataSource", - "RuleMetricDataSource", - "RuleWebhookAction", - "ScaleAction", - "ScaleCapacity", - "ScaleRule", - "ScaleRuleMetricDimension", - "SenderAuthorization", - "ThresholdRuleCondition", - "TimeWindow", - "WebhookNotification", - "ComparisonOperationType", - "ConditionOperator", - "EventLevel", - "MetricStatisticType", - "RecurrenceFrequency", - "ScaleDirection", - "ScaleRuleMetricDimensionOperationType", - "ScaleType", - "TimeAggregationOperator", - "TimeAggregationType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py deleted file mode 100644 index 82dc0158f2116..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py +++ /dev/null @@ -1,2427 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class AlertRuleResource(Resource): # pylint: disable=too-many-instance-attributes - """The alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar name_properties_name: the name of the alert rule. Required. - :vartype name_properties_name: str - :ivar description: the description of the alert rule that will be included in the alert email. - :vartype description: str - :ivar provisioning_state: the provisioning state. - :vartype provisioning_state: str - :ivar is_enabled: the flag that indicates whether the alert rule is enabled. Required. - :vartype is_enabled: bool - :ivar condition: the condition that results in the alert rule being activated. Required. - :vartype condition: ~azure.mgmt.monitor.v2015_04_01.models.RuleCondition - :ivar action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :vartype action: ~azure.mgmt.monitor.v2015_04_01.models.RuleAction - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2015_04_01.models.RuleAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "name_properties_name": {"required": True}, - "is_enabled": {"required": True}, - "condition": {"required": True}, - "last_updated_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "RuleCondition"}, - "action": {"key": "properties.action", "type": "RuleAction"}, - "actions": {"key": "properties.actions", "type": "[RuleAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - location: str, - name_properties_name: str, - is_enabled: bool, - condition: "_models.RuleCondition", - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - provisioning_state: Optional[str] = None, - action: Optional["_models.RuleAction"] = None, - actions: Optional[List["_models.RuleAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword name_properties_name: the name of the alert rule. Required. - :paramtype name_properties_name: str - :keyword description: the description of the alert rule that will be included in the alert - email. - :paramtype description: str - :keyword provisioning_state: the provisioning state. - :paramtype provisioning_state: str - :keyword is_enabled: the flag that indicates whether the alert rule is enabled. Required. - :paramtype is_enabled: bool - :keyword condition: the condition that results in the alert rule being activated. Required. - :paramtype condition: ~azure.mgmt.monitor.v2015_04_01.models.RuleCondition - :keyword action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :paramtype action: ~azure.mgmt.monitor.v2015_04_01.models.RuleAction - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2015_04_01.models.RuleAction] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.name_properties_name = name_properties_name - self.description = description - self.provisioning_state = provisioning_state - self.is_enabled = is_enabled - self.condition = condition - self.action = action - self.actions = actions - self.last_updated_time = None - - -class AlertRuleResourceCollection(_serialization.Model): - """Represents a collection of alert rule resources. - - :ivar value: the values for the alert rule resources. - :vartype value: list[~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AlertRuleResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: the values for the alert rule resources. - :paramtype value: list[~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource] - """ - super().__init__(**kwargs) - self.value = value - - -class AlertRuleResourcePatch(_serialization.Model): - """The alert rule object for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar name: the name of the alert rule. - :vartype name: str - :ivar description: the description of the alert rule that will be included in the alert email. - :vartype description: str - :ivar provisioning_state: the provisioning state. - :vartype provisioning_state: str - :ivar is_enabled: the flag that indicates whether the alert rule is enabled. - :vartype is_enabled: bool - :ivar condition: the condition that results in the alert rule being activated. - :vartype condition: ~azure.mgmt.monitor.v2015_04_01.models.RuleCondition - :ivar action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :vartype action: ~azure.mgmt.monitor.v2015_04_01.models.RuleAction - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2015_04_01.models.RuleAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - """ - - _validation = { - "last_updated_time": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "name": {"key": "properties.name", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "RuleCondition"}, - "action": {"key": "properties.action", "type": "RuleAction"}, - "actions": {"key": "properties.actions", "type": "[RuleAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - name: Optional[str] = None, - description: Optional[str] = None, - provisioning_state: Optional[str] = None, - is_enabled: Optional[bool] = None, - condition: Optional["_models.RuleCondition"] = None, - action: Optional["_models.RuleAction"] = None, - actions: Optional[List["_models.RuleAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword name: the name of the alert rule. - :paramtype name: str - :keyword description: the description of the alert rule that will be included in the alert - email. - :paramtype description: str - :keyword provisioning_state: the provisioning state. - :paramtype provisioning_state: str - :keyword is_enabled: the flag that indicates whether the alert rule is enabled. - :paramtype is_enabled: bool - :keyword condition: the condition that results in the alert rule being activated. - :paramtype condition: ~azure.mgmt.monitor.v2015_04_01.models.RuleCondition - :keyword action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :paramtype action: ~azure.mgmt.monitor.v2015_04_01.models.RuleAction - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2015_04_01.models.RuleAction] - """ - super().__init__(**kwargs) - self.tags = tags - self.name = name - self.description = description - self.provisioning_state = provisioning_state - self.is_enabled = is_enabled - self.condition = condition - self.action = action - self.actions = actions - self.last_updated_time = None - - -class AutoscaleNotification(_serialization.Model): - """Autoscale notification. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar operation: the operation associated with the notification and its value must be "scale". - Required. Default value is "Scale". - :vartype operation: str - :ivar email: the email notification. - :vartype email: ~azure.mgmt.monitor.v2015_04_01.models.EmailNotification - :ivar webhooks: the collection of webhook notifications. - :vartype webhooks: list[~azure.mgmt.monitor.v2015_04_01.models.WebhookNotification] - """ - - _validation = { - "operation": {"required": True, "constant": True}, - } - - _attribute_map = { - "operation": {"key": "operation", "type": "str"}, - "email": {"key": "email", "type": "EmailNotification"}, - "webhooks": {"key": "webhooks", "type": "[WebhookNotification]"}, - } - - operation = "Scale" - - def __init__( - self, - *, - email: Optional["_models.EmailNotification"] = None, - webhooks: Optional[List["_models.WebhookNotification"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword email: the email notification. - :paramtype email: ~azure.mgmt.monitor.v2015_04_01.models.EmailNotification - :keyword webhooks: the collection of webhook notifications. - :paramtype webhooks: list[~azure.mgmt.monitor.v2015_04_01.models.WebhookNotification] - """ - super().__init__(**kwargs) - self.email = email - self.webhooks = webhooks - - -class AutoscaleProfile(_serialization.Model): - """Autoscale profile. - - All required parameters must be populated in order to send to Azure. - - :ivar name: the name of the profile. Required. - :vartype name: str - :ivar capacity: the number of instances that can be used during this profile. Required. - :vartype capacity: ~azure.mgmt.monitor.v2015_04_01.models.ScaleCapacity - :ivar rules: the collection of rules that provide the triggers and parameters for the scaling - action. A maximum of 10 rules can be specified. Required. - :vartype rules: list[~azure.mgmt.monitor.v2015_04_01.models.ScaleRule] - :ivar fixed_date: the specific date-time for the profile. This element is not used if the - Recurrence element is used. - :vartype fixed_date: ~azure.mgmt.monitor.v2015_04_01.models.TimeWindow - :ivar recurrence: the repeating times at which this profile begins. This element is not used if - the FixedDate element is used. - :vartype recurrence: ~azure.mgmt.monitor.v2015_04_01.models.Recurrence - """ - - _validation = { - "name": {"required": True}, - "capacity": {"required": True}, - "rules": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "capacity": {"key": "capacity", "type": "ScaleCapacity"}, - "rules": {"key": "rules", "type": "[ScaleRule]"}, - "fixed_date": {"key": "fixedDate", "type": "TimeWindow"}, - "recurrence": {"key": "recurrence", "type": "Recurrence"}, - } - - def __init__( - self, - *, - name: str, - capacity: "_models.ScaleCapacity", - rules: List["_models.ScaleRule"], - fixed_date: Optional["_models.TimeWindow"] = None, - recurrence: Optional["_models.Recurrence"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: the name of the profile. Required. - :paramtype name: str - :keyword capacity: the number of instances that can be used during this profile. Required. - :paramtype capacity: ~azure.mgmt.monitor.v2015_04_01.models.ScaleCapacity - :keyword rules: the collection of rules that provide the triggers and parameters for the - scaling action. A maximum of 10 rules can be specified. Required. - :paramtype rules: list[~azure.mgmt.monitor.v2015_04_01.models.ScaleRule] - :keyword fixed_date: the specific date-time for the profile. This element is not used if the - Recurrence element is used. - :paramtype fixed_date: ~azure.mgmt.monitor.v2015_04_01.models.TimeWindow - :keyword recurrence: the repeating times at which this profile begins. This element is not used - if the FixedDate element is used. - :paramtype recurrence: ~azure.mgmt.monitor.v2015_04_01.models.Recurrence - """ - super().__init__(**kwargs) - self.name = name - self.capacity = capacity - self.rules = rules - self.fixed_date = fixed_date - self.recurrence = recurrence - - -class AutoscaleSettingResource(Resource): # pylint: disable=too-many-instance-attributes - """The autoscale setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. Required. - :vartype profiles: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleProfile] - :ivar notifications: the collection of notifications. - :vartype notifications: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleNotification] - :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :vartype enabled: bool - :ivar name_properties_name: the name of the autoscale setting. - :vartype name_properties_name: str - :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting - should be added to. - :vartype target_resource_uri: str - :ivar target_resource_location: the location of the resource that the autoscale setting should - be added to. - :vartype target_resource_location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "profiles": {"required": True, "max_items": 20, "min_items": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, - "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, - "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - profiles: List["_models.AutoscaleProfile"], - tags: Optional[Dict[str, str]] = None, - notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: bool = False, - name_properties_name: Optional[str] = None, - target_resource_uri: Optional[str] = None, - target_resource_location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. Required. - :paramtype profiles: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleProfile] - :keyword notifications: the collection of notifications. - :paramtype notifications: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleNotification] - :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :paramtype enabled: bool - :keyword name_properties_name: the name of the autoscale setting. - :paramtype name_properties_name: str - :keyword target_resource_uri: the resource identifier of the resource that the autoscale - setting should be added to. - :paramtype target_resource_uri: str - :keyword target_resource_location: the location of the resource that the autoscale setting - should be added to. - :paramtype target_resource_location: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.profiles = profiles - self.notifications = notifications - self.enabled = enabled - self.name_properties_name = name_properties_name - self.target_resource_uri = target_resource_uri - self.target_resource_location = target_resource_location - - -class AutoscaleSettingResourceCollection(_serialization.Model): - """Represents a collection of autoscale setting resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values for the autoscale setting resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource] - :ivar next_link: URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AutoscaleSettingResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: the values for the autoscale setting resources. Required. - :paramtype value: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource] - :keyword next_link: URL to get the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AutoscaleSettingResourcePatch(_serialization.Model): - """The autoscale setting object for patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. - :vartype profiles: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleProfile] - :ivar notifications: the collection of notifications. - :vartype notifications: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleNotification] - :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :vartype enabled: bool - :ivar name: the name of the autoscale setting. - :vartype name: str - :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting - should be added to. - :vartype target_resource_uri: str - :ivar target_resource_location: the location of the resource that the autoscale setting should - be added to. - :vartype target_resource_location: str - """ - - _validation = { - "profiles": {"max_items": 20, "min_items": 0}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, - "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "name": {"key": "properties.name", "type": "str"}, - "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, - "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - profiles: Optional[List["_models.AutoscaleProfile"]] = None, - notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: bool = False, - name: Optional[str] = None, - target_resource_uri: Optional[str] = None, - target_resource_location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. - :paramtype profiles: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleProfile] - :keyword notifications: the collection of notifications. - :paramtype notifications: list[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleNotification] - :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :paramtype enabled: bool - :keyword name: the name of the autoscale setting. - :paramtype name: str - :keyword target_resource_uri: the resource identifier of the resource that the autoscale - setting should be added to. - :paramtype target_resource_uri: str - :keyword target_resource_location: the location of the resource that the autoscale setting - should be added to. - :paramtype target_resource_location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.profiles = profiles - self.notifications = notifications - self.enabled = enabled - self.name = name - self.target_resource_uri = target_resource_uri - self.target_resource_location = target_resource_location - - -class EmailNotification(_serialization.Model): - """Email notification of an autoscale event. - - :ivar send_to_subscription_administrator: a value indicating whether to send email to - subscription administrator. - :vartype send_to_subscription_administrator: bool - :ivar send_to_subscription_co_administrators: a value indicating whether to send email to - subscription co-administrators. - :vartype send_to_subscription_co_administrators: bool - :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case - this attribute will be ignored. - :vartype custom_emails: list[str] - """ - - _attribute_map = { - "send_to_subscription_administrator": {"key": "sendToSubscriptionAdministrator", "type": "bool"}, - "send_to_subscription_co_administrators": {"key": "sendToSubscriptionCoAdministrators", "type": "bool"}, - "custom_emails": {"key": "customEmails", "type": "[str]"}, - } - - def __init__( - self, - *, - send_to_subscription_administrator: bool = False, - send_to_subscription_co_administrators: bool = False, - custom_emails: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword send_to_subscription_administrator: a value indicating whether to send email to - subscription administrator. - :paramtype send_to_subscription_administrator: bool - :keyword send_to_subscription_co_administrators: a value indicating whether to send email to - subscription co-administrators. - :paramtype send_to_subscription_co_administrators: bool - :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case - this attribute will be ignored. - :paramtype custom_emails: list[str] - """ - super().__init__(**kwargs) - self.send_to_subscription_administrator = send_to_subscription_administrator - self.send_to_subscription_co_administrators = send_to_subscription_co_administrators - self.custom_emails = custom_emails - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class EventCategoryCollection(_serialization.Model): - """A collection of event categories. Currently possible values are: Administrative, Security, - ServiceHealth, Alert, Recommendation, Policy. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the list that includes the Azure event categories. Required. - :vartype value: list[~azure.mgmt.monitor.v2015_04_01.models.LocalizableString] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[LocalizableString]"}, - } - - def __init__(self, *, value: List["_models.LocalizableString"], **kwargs: Any) -> None: - """ - :keyword value: the list that includes the Azure event categories. Required. - :paramtype value: list[~azure.mgmt.monitor.v2015_04_01.models.LocalizableString] - """ - super().__init__(**kwargs) - self.value = value - - -class EventData(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The Azure event log entries are of type EventData. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar authorization: The sender authorization information. - :vartype authorization: ~azure.mgmt.monitor.v2015_04_01.models.SenderAuthorization - :ivar claims: key value pairs to identify ARM permissions. - :vartype claims: dict[str, str] - :ivar caller: the email address of the user who has performed the operation, the UPN claim or - SPN claim based on availability. - :vartype caller: str - :ivar description: the description of the event. - :vartype description: str - :ivar id: the Id of this event as required by ARM for RBAC. It contains the EventDataID and a - timestamp information. - :vartype id: str - :ivar event_data_id: the event data Id. This is a unique identifier for an event. - :vartype event_data_id: str - :ivar correlation_id: 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. - :vartype correlation_id: str - :ivar event_name: the event name. This value should not be confused with OperationName. For - practical purposes, OperationName might be more appealing to end users. - :vartype event_name: ~azure.mgmt.monitor.v2015_04_01.models.LocalizableString - :ivar category: the event category. - :vartype category: ~azure.mgmt.monitor.v2015_04_01.models.LocalizableString - :ivar http_request: 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). - :vartype http_request: ~azure.mgmt.monitor.v2015_04_01.models.HttpRequestInfo - :ivar level: the event level. Known values are: "Critical", "Error", "Warning", - "Informational", and "Verbose". - :vartype level: str or ~azure.mgmt.monitor.v2015_04_01.models.EventLevel - :ivar resource_group_name: the resource group name of the impacted resource. - :vartype resource_group_name: str - :ivar resource_provider_name: the resource provider name of the impacted resource. - :vartype resource_provider_name: ~azure.mgmt.monitor.v2015_04_01.models.LocalizableString - :ivar resource_id: the resource uri that uniquely identifies the resource that caused this - event. - :vartype resource_id: str - :ivar resource_type: the resource type. - :vartype resource_type: ~azure.mgmt.monitor.v2015_04_01.models.LocalizableString - :ivar operation_id: It is usually a GUID shared among the events corresponding to single - operation. This value should not be confused with EventName. - :vartype operation_id: str - :ivar operation_name: the operation name. - :vartype operation_name: ~azure.mgmt.monitor.v2015_04_01.models.LocalizableString - :ivar properties: the set of pairs (usually a Dictionary) that - includes details about the event. - :vartype properties: dict[str, str] - :ivar status: a string describing the status of the operation. Some typical values are: - Started, In progress, Succeeded, Failed, Resolved. - :vartype status: ~azure.mgmt.monitor.v2015_04_01.models.LocalizableString - :ivar sub_status: 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). - :vartype sub_status: ~azure.mgmt.monitor.v2015_04_01.models.LocalizableString - :ivar event_timestamp: the timestamp of when the event was generated by the Azure service - processing the request corresponding the event. It in ISO 8601 format. - :vartype event_timestamp: ~datetime.datetime - :ivar submission_timestamp: 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. - :vartype submission_timestamp: ~datetime.datetime - :ivar subscription_id: the Azure subscription Id usually a GUID. - :vartype subscription_id: str - :ivar tenant_id: the Azure tenant Id. - :vartype tenant_id: str - """ - - _validation = { - "authorization": {"readonly": True}, - "claims": {"readonly": True}, - "caller": {"readonly": True}, - "description": {"readonly": True}, - "id": {"readonly": True}, - "event_data_id": {"readonly": True}, - "correlation_id": {"readonly": True}, - "event_name": {"readonly": True}, - "category": {"readonly": True}, - "http_request": {"readonly": True}, - "level": {"readonly": True}, - "resource_group_name": {"readonly": True}, - "resource_provider_name": {"readonly": True}, - "resource_id": {"readonly": True}, - "resource_type": {"readonly": True}, - "operation_id": {"readonly": True}, - "operation_name": {"readonly": True}, - "properties": {"readonly": True}, - "status": {"readonly": True}, - "sub_status": {"readonly": True}, - "event_timestamp": {"readonly": True}, - "submission_timestamp": {"readonly": True}, - "subscription_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "authorization": {"key": "authorization", "type": "SenderAuthorization"}, - "claims": {"key": "claims", "type": "{str}"}, - "caller": {"key": "caller", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "event_data_id": {"key": "eventDataId", "type": "str"}, - "correlation_id": {"key": "correlationId", "type": "str"}, - "event_name": {"key": "eventName", "type": "LocalizableString"}, - "category": {"key": "category", "type": "LocalizableString"}, - "http_request": {"key": "httpRequest", "type": "HttpRequestInfo"}, - "level": {"key": "level", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "resource_provider_name": {"key": "resourceProviderName", "type": "LocalizableString"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "resource_type": {"key": "resourceType", "type": "LocalizableString"}, - "operation_id": {"key": "operationId", "type": "str"}, - "operation_name": {"key": "operationName", "type": "LocalizableString"}, - "properties": {"key": "properties", "type": "{str}"}, - "status": {"key": "status", "type": "LocalizableString"}, - "sub_status": {"key": "subStatus", "type": "LocalizableString"}, - "event_timestamp": {"key": "eventTimestamp", "type": "iso-8601"}, - "submission_timestamp": {"key": "submissionTimestamp", "type": "iso-8601"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: # pylint: disable=too-many-locals - """ """ - super().__init__(**kwargs) - self.authorization = None - self.claims = None - self.caller = None - self.description = None - self.id = None - self.event_data_id = None - self.correlation_id = None - self.event_name = None - self.category = None - self.http_request = None - self.level = None - self.resource_group_name = None - self.resource_provider_name = None - self.resource_id = None - self.resource_type = None - self.operation_id = None - self.operation_name = None - self.properties = None - self.status = None - self.sub_status = None - self.event_timestamp = None - self.submission_timestamp = None - self.subscription_id = None - self.tenant_id = None - - -class EventDataCollection(_serialization.Model): - """Represents collection of events. - - All required parameters must be populated in order to send to Azure. - - :ivar value: this list that includes the Azure audit logs. Required. - :vartype value: list[~azure.mgmt.monitor.v2015_04_01.models.EventData] - :ivar next_link: Provides the link to retrieve the next set of events. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[EventData]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.EventData"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: this list that includes the Azure audit logs. Required. - :paramtype value: list[~azure.mgmt.monitor.v2015_04_01.models.EventData] - :keyword next_link: Provides the link to retrieve the next set of events. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class HttpRequestInfo(_serialization.Model): - """The Http request info. - - :ivar client_request_id: the client request id. - :vartype client_request_id: str - :ivar client_ip_address: the client Ip Address. - :vartype client_ip_address: str - :ivar method: the Http request method. - :vartype method: str - :ivar uri: the Uri. - :vartype uri: str - """ - - _attribute_map = { - "client_request_id": {"key": "clientRequestId", "type": "str"}, - "client_ip_address": {"key": "clientIpAddress", "type": "str"}, - "method": {"key": "method", "type": "str"}, - "uri": {"key": "uri", "type": "str"}, - } - - def __init__( - self, - *, - client_request_id: Optional[str] = None, - client_ip_address: Optional[str] = None, - method: Optional[str] = None, - uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword client_request_id: the client request id. - :paramtype client_request_id: str - :keyword client_ip_address: the client Ip Address. - :paramtype client_ip_address: str - :keyword method: the Http request method. - :paramtype method: str - :keyword uri: the Uri. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.client_request_id = client_request_id - self.client_ip_address = client_ip_address - self.method = method - self.uri = uri - - -class LocalizableString(_serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the invariant value. Required. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: the invariant value. Required. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class RuleCondition(_serialization.Model): - """The condition that results in the alert rule being activated. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": "LocationThresholdRuleCondition", - "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": "ManagementEventRuleCondition", - "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": "ThresholdRuleCondition", - } - } - - def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs: Any) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - self.data_source = data_source - - -class LocationThresholdRuleCondition(RuleCondition): - """A rule condition based on a certain number of locations failing. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - :ivar failed_location_count: the number of locations that must fail to activate the alert. - Required. - :vartype failed_location_count: int - """ - - _validation = { - "odata_type": {"required": True}, - "failed_location_count": {"required": True, "minimum": 0}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "window_size": {"key": "windowSize", "type": "duration"}, - "failed_location_count": {"key": "failedLocationCount", "type": "int"}, - } - - def __init__( - self, - *, - failed_location_count: int, - data_source: Optional["_models.RuleDataSource"] = None, - window_size: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - :keyword failed_location_count: the number of locations that must fail to activate the alert. - Required. - :paramtype failed_location_count: int - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" - self.window_size = window_size - self.failed_location_count = failed_location_count - - -class ManagementEventAggregationCondition(_serialization.Model): - """How the data that is collected should be combined over time. - - :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2015_04_01.models.ConditionOperator - :ivar threshold: The threshold value that activates the alert. - :vartype threshold: float - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - """ - - _attribute_map = { - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "window_size": {"key": "windowSize", "type": "duration"}, - } - - def __init__( - self, - *, - operator: Optional[Union[str, "_models.ConditionOperator"]] = None, - threshold: Optional[float] = None, - window_size: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword operator: the condition operator. Known values are: "GreaterThan", - "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2015_04_01.models.ConditionOperator - :keyword threshold: The threshold value that activates the alert. - :paramtype threshold: float - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.operator = operator - self.threshold = threshold - self.window_size = window_size - - -class ManagementEventRuleCondition(RuleCondition): - """A management event rule condition. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - :ivar aggregation: 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. - :vartype aggregation: - ~azure.mgmt.monitor.v2015_04_01.models.ManagementEventAggregationCondition - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "aggregation": {"key": "aggregation", "type": "ManagementEventAggregationCondition"}, - } - - def __init__( - self, - *, - data_source: Optional["_models.RuleDataSource"] = None, - aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - :keyword aggregation: 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. - :paramtype aggregation: - ~azure.mgmt.monitor.v2015_04_01.models.ManagementEventAggregationCondition - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" - self.aggregation = aggregation - - -class MetricTrigger(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The trigger that results in a scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar metric_name: the name of the metric that defines what the rule monitors. Required. - :vartype metric_name: str - :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. - :vartype metric_namespace: str - :ivar metric_resource_uri: the resource identifier of the resource the rule monitors. Required. - :vartype metric_resource_uri: str - :ivar metric_resource_location: the location of the resource the rule monitors. - :vartype metric_resource_location: str - :ivar time_grain: 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. - Required. - :vartype time_grain: ~datetime.timedelta - :ivar statistic: the metric statistic type. How the metrics from multiple instances are - combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". - :vartype statistic: str or ~azure.mgmt.monitor.v2015_04_01.models.MetricStatisticType - :ivar time_window: 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. Required. - :vartype time_window: ~datetime.timedelta - :ivar time_aggregation: time aggregation type. How the data that is collected should be - combined over time. The default value is Average. Required. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", and "Last". - :vartype time_aggregation: str or ~azure.mgmt.monitor.v2015_04_01.models.TimeAggregationType - :ivar operator: the operator that is used to compare the metric data and the threshold. - Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2015_04_01.models.ComparisonOperationType - :ivar threshold: the threshold of the metric that triggers the scale action. Required. - :vartype threshold: float - :ivar dimensions: List of dimension conditions. For example: - [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :vartype dimensions: list[~azure.mgmt.monitor.v2015_04_01.models.ScaleRuleMetricDimension] - :ivar divide_per_instance: a value indicating whether metric should divide per instance. - :vartype divide_per_instance: bool - """ - - _validation = { - "metric_name": {"required": True}, - "metric_resource_uri": {"required": True}, - "time_grain": {"required": True}, - "statistic": {"required": True}, - "time_window": {"required": True}, - "time_aggregation": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "metric_name": {"key": "metricName", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "metric_resource_uri": {"key": "metricResourceUri", "type": "str"}, - "metric_resource_location": {"key": "metricResourceLocation", "type": "str"}, - "time_grain": {"key": "timeGrain", "type": "duration"}, - "statistic": {"key": "statistic", "type": "str"}, - "time_window": {"key": "timeWindow", "type": "duration"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "dimensions": {"key": "dimensions", "type": "[ScaleRuleMetricDimension]"}, - "divide_per_instance": {"key": "dividePerInstance", "type": "bool"}, - } - - def __init__( - self, - *, - metric_name: str, - metric_resource_uri: str, - time_grain: datetime.timedelta, - statistic: Union[str, "_models.MetricStatisticType"], - time_window: datetime.timedelta, - time_aggregation: Union[str, "_models.TimeAggregationType"], - operator: Union[str, "_models.ComparisonOperationType"], - threshold: float, - metric_namespace: Optional[str] = None, - metric_resource_location: Optional[str] = None, - dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, - divide_per_instance: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric_name: the name of the metric that defines what the rule monitors. Required. - :paramtype metric_name: str - :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. - :paramtype metric_namespace: str - :keyword metric_resource_uri: the resource identifier of the resource the rule monitors. - Required. - :paramtype metric_resource_uri: str - :keyword metric_resource_location: the location of the resource the rule monitors. - :paramtype metric_resource_location: str - :keyword time_grain: 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. Required. - :paramtype time_grain: ~datetime.timedelta - :keyword statistic: the metric statistic type. How the metrics from multiple instances are - combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". - :paramtype statistic: str or ~azure.mgmt.monitor.v2015_04_01.models.MetricStatisticType - :keyword time_window: 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. Required. - :paramtype time_window: ~datetime.timedelta - :keyword time_aggregation: time aggregation type. How the data that is collected should be - combined over time. The default value is Average. Required. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", and "Last". - :paramtype time_aggregation: str or ~azure.mgmt.monitor.v2015_04_01.models.TimeAggregationType - :keyword operator: the operator that is used to compare the metric data and the threshold. - Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2015_04_01.models.ComparisonOperationType - :keyword threshold: the threshold of the metric that triggers the scale action. Required. - :paramtype threshold: float - :keyword dimensions: List of dimension conditions. For example: - [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :paramtype dimensions: list[~azure.mgmt.monitor.v2015_04_01.models.ScaleRuleMetricDimension] - :keyword divide_per_instance: a value indicating whether metric should divide per instance. - :paramtype divide_per_instance: bool - """ - super().__init__(**kwargs) - self.metric_name = metric_name - self.metric_namespace = metric_namespace - self.metric_resource_uri = metric_resource_uri - self.metric_resource_location = metric_resource_location - self.time_grain = time_grain - self.statistic = statistic - self.time_window = time_window - self.time_aggregation = time_aggregation - self.operator = operator - self.threshold = threshold - self.dimensions = dimensions - self.divide_per_instance = divide_per_instance - - -class Operation(_serialization.Model): - """Microsoft Insights API operation definition. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: Display metadata associated with the operation. - :vartype display: ~azure.mgmt.monitor.v2015_04_01.models.OperationDisplay - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - } - - def __init__( - self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Operation name: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword display: Display metadata associated with the operation. - :paramtype display: ~azure.mgmt.monitor.v2015_04_01.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = name - self.display = display - - -class OperationDisplay(_serialization.Model): - """Display metadata associated with the operation. - - :ivar provider: Service provider: Microsoft.Insights. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - """ - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - } - - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: Service provider: Microsoft.Insights. - :paramtype provider: str - :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :paramtype resource: str - :keyword operation: Operation type: Read, write, delete, etc. - :paramtype operation: str - """ - super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - - -class OperationListResult(_serialization.Model): - """Result of the request to list Microsoft.Insights operations. It contains a list of operations - and a URL link to get the next set of results. - - :ivar value: List of operations supported by the Microsoft.Insights provider. - :vartype value: list[~azure.mgmt.monitor.v2015_04_01.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of operations supported by the Microsoft.Insights provider. - :paramtype value: list[~azure.mgmt.monitor.v2015_04_01.models.Operation] - :keyword next_link: URL to get the next set of operation list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Recurrence(_serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate - element is used. - - All required parameters must be populated in order to send to Azure. - - :ivar frequency: 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. Required. Known values are: "None", "Second", - "Minute", "Hour", "Day", "Week", "Month", and "Year". - :vartype frequency: str or ~azure.mgmt.monitor.v2015_04_01.models.RecurrenceFrequency - :ivar schedule: the scheduling constraints for when the profile begins. Required. - :vartype schedule: ~azure.mgmt.monitor.v2015_04_01.models.RecurrentSchedule - """ - - _validation = { - "frequency": {"required": True}, - "schedule": {"required": True}, - } - - _attribute_map = { - "frequency": {"key": "frequency", "type": "str"}, - "schedule": {"key": "schedule", "type": "RecurrentSchedule"}, - } - - def __init__( - self, - *, - frequency: Union[str, "_models.RecurrenceFrequency"], - schedule: "_models.RecurrentSchedule", - **kwargs: Any - ) -> None: - """ - :keyword frequency: 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. Required. Known values are: "None", - "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year". - :paramtype frequency: str or ~azure.mgmt.monitor.v2015_04_01.models.RecurrenceFrequency - :keyword schedule: the scheduling constraints for when the profile begins. Required. - :paramtype schedule: ~azure.mgmt.monitor.v2015_04_01.models.RecurrentSchedule - """ - super().__init__(**kwargs) - self.frequency = frequency - self.schedule = schedule - - -class RecurrentSchedule(_serialization.Model): - """The scheduling constraints for when the profile begins. - - All required parameters must be populated in order to send to Azure. - - :ivar time_zone: 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. Required. - :vartype time_zone: str - :ivar days: the collection of days that the profile takes effect on. Possible values are Sunday - through Saturday. Required. - :vartype days: list[str] - :ivar hours: 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). Required. - :vartype hours: list[int] - :ivar minutes: A collection of minutes at which the profile takes effect at. Required. - :vartype minutes: list[int] - """ - - _validation = { - "time_zone": {"required": True}, - "days": {"required": True}, - "hours": {"required": True}, - "minutes": {"required": True}, - } - - _attribute_map = { - "time_zone": {"key": "timeZone", "type": "str"}, - "days": {"key": "days", "type": "[str]"}, - "hours": {"key": "hours", "type": "[int]"}, - "minutes": {"key": "minutes", "type": "[int]"}, - } - - def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any) -> None: - """ - :keyword time_zone: 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. Required. - :paramtype time_zone: str - :keyword days: the collection of days that the profile takes effect on. Possible values are - Sunday through Saturday. Required. - :paramtype days: list[str] - :keyword hours: 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). Required. - :paramtype hours: list[int] - :keyword minutes: A collection of minutes at which the profile takes effect at. Required. - :paramtype minutes: list[int] - """ - super().__init__(**kwargs) - self.time_zone = time_zone - self.days = days - self.hours = hours - self.minutes = minutes - - -class RuleAction(_serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is - resolved. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RuleEmailAction, RuleWebhookAction - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": "RuleEmailAction", - "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": "RuleWebhookAction", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - - -class RuleDataSource(_serialization.Model): - """The resource from which the rule collects its data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RuleManagementEventDataSource, RuleMetricDataSource - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": "RuleManagementEventDataSource", - "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": "RuleMetricDataSource", - } - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - self.resource_uri = resource_uri - self.legacy_resource_id = legacy_resource_id - self.resource_location = resource_location - self.metric_namespace = metric_namespace - - -class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is - always RuleEmailAction in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the - service should be notified when the alert is activated. - :vartype send_to_service_owners: bool - :ivar custom_emails: the list of administrator's custom email addresses to notify of the - activation of the alert. - :vartype custom_emails: list[str] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "send_to_service_owners": {"key": "sendToServiceOwners", "type": "bool"}, - "custom_emails": {"key": "customEmails", "type": "[str]"}, - } - - def __init__( - self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :paramtype send_to_service_owners: bool - :keyword custom_emails: the list of administrator's custom email addresses to notify of the - activation of the alert. - :paramtype custom_emails: list[str] - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" - self.send_to_service_owners = send_to_service_owners - self.custom_emails = custom_emails - - -class RuleManagementEventClaimsDataSource(_serialization.Model): - """The claims for a rule management event data source. - - :ivar email_address: the email address. - :vartype email_address: str - """ - - _attribute_map = { - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, email_address: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword email_address: the email address. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.email_address = email_address - - -class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes - """A rule management event data source. The discriminator fields is always - RuleManagementEventDataSource in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - :ivar event_name: the event name. - :vartype event_name: str - :ivar event_source: the event source. - :vartype event_source: str - :ivar level: the level. - :vartype level: str - :ivar operation_name: The name of the operation that should be checked for. If no name is - provided, any operation will match. - :vartype operation_name: str - :ivar resource_group_name: the resource group name. - :vartype resource_group_name: str - :ivar resource_provider_name: the resource provider name. - :vartype resource_provider_name: str - :ivar status: The status of the operation that should be checked for. If no status is provided, - any status will match. - :vartype status: str - :ivar sub_status: the substatus. - :vartype sub_status: str - :ivar claims: the claims. - :vartype claims: ~azure.mgmt.monitor.v2015_04_01.models.RuleManagementEventClaimsDataSource - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "event_name": {"key": "eventName", "type": "str"}, - "event_source": {"key": "eventSource", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "operation_name": {"key": "operationName", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "resource_provider_name": {"key": "resourceProviderName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "sub_status": {"key": "subStatus", "type": "str"}, - "claims": {"key": "claims", "type": "RuleManagementEventClaimsDataSource"}, - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - event_name: Optional[str] = None, - event_source: Optional[str] = None, - level: Optional[str] = None, - operation_name: Optional[str] = None, - resource_group_name: Optional[str] = None, - resource_provider_name: Optional[str] = None, - status: Optional[str] = None, - sub_status: Optional[str] = None, - claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - :keyword event_name: the event name. - :paramtype event_name: str - :keyword event_source: the event source. - :paramtype event_source: str - :keyword level: the level. - :paramtype level: str - :keyword operation_name: The name of the operation that should be checked for. If no name is - provided, any operation will match. - :paramtype operation_name: str - :keyword resource_group_name: the resource group name. - :paramtype resource_group_name: str - :keyword resource_provider_name: the resource provider name. - :paramtype resource_provider_name: str - :keyword status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :paramtype status: str - :keyword sub_status: the substatus. - :paramtype sub_status: str - :keyword claims: the claims. - :paramtype claims: ~azure.mgmt.monitor.v2015_04_01.models.RuleManagementEventClaimsDataSource - """ - super().__init__( - resource_uri=resource_uri, - legacy_resource_id=legacy_resource_id, - resource_location=resource_location, - metric_namespace=metric_namespace, - **kwargs - ) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" - self.event_name = event_name - self.event_source = event_source - self.level = level - self.operation_name = operation_name - self.resource_group_name = resource_group_name - self.resource_provider_name = resource_provider_name - self.status = status - self.sub_status = sub_status - self.claims = claims - - -class RuleMetricDataSource(RuleDataSource): - """A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - :ivar metric_name: the name of the metric that defines what the rule monitors. - :vartype metric_name: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "metric_name": {"key": "metricName", "type": "str"}, - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - metric_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - :keyword metric_name: the name of the metric that defines what the rule monitors. - :paramtype metric_name: str - """ - super().__init__( - resource_uri=resource_uri, - legacy_resource_id=legacy_resource_id, - resource_location=resource_location, - metric_namespace=metric_namespace, - **kwargs - ) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" - self.metric_name = metric_name - - -class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator - is always RuleWebhookAction in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - :ivar service_uri: the service uri to Post the notification when the alert activates or - resolves. - :vartype service_uri: str - :ivar properties: the dictionary of custom properties to include with the post operation. These - data are appended to the webhook payload. - :vartype properties: dict[str, str] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "properties": {"key": "properties", "type": "{str}"}, - } - - def __init__( - self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword service_uri: the service uri to Post the notification when the alert activates or - resolves. - :paramtype service_uri: str - :keyword properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" - self.service_uri = service_uri - self.properties = properties - - -class ScaleAction(_serialization.Model): - """The parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar direction: the scale direction. Whether the scaling action increases or decreases the - number of instances. Required. Known values are: "None", "Increase", and "Decrease". - :vartype direction: str or ~azure.mgmt.monitor.v2015_04_01.models.ScaleDirection - :ivar type: the type of action that should occur when the scale rule fires. Required. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". - :vartype type: str or ~azure.mgmt.monitor.v2015_04_01.models.ScaleType - :ivar value: the number of instances that are involved in the scaling action. This value must - be 1 or greater. The default value is 1. - :vartype value: str - :ivar cooldown: 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. Required. - :vartype cooldown: ~datetime.timedelta - """ - - _validation = { - "direction": {"required": True}, - "type": {"required": True}, - "cooldown": {"required": True}, - } - - _attribute_map = { - "direction": {"key": "direction", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "cooldown": {"key": "cooldown", "type": "duration"}, - } - - def __init__( - self, - *, - direction: Union[str, "_models.ScaleDirection"], - type: Union[str, "_models.ScaleType"], - cooldown: datetime.timedelta, - value: str = "1", - **kwargs: Any - ) -> None: - """ - :keyword direction: the scale direction. Whether the scaling action increases or decreases the - number of instances. Required. Known values are: "None", "Increase", and "Decrease". - :paramtype direction: str or ~azure.mgmt.monitor.v2015_04_01.models.ScaleDirection - :keyword type: the type of action that should occur when the scale rule fires. Required. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". - :paramtype type: str or ~azure.mgmt.monitor.v2015_04_01.models.ScaleType - :keyword value: the number of instances that are involved in the scaling action. This value - must be 1 or greater. The default value is 1. - :paramtype value: str - :keyword cooldown: 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. Required. - :paramtype cooldown: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.direction = direction - self.type = type - self.value = value - self.cooldown = cooldown - - -class ScaleCapacity(_serialization.Model): - """The number of instances that can be used during this profile. - - All required parameters must be populated in order to send to Azure. - - :ivar minimum: the minimum number of instances for the resource. Required. - :vartype minimum: str - :ivar maximum: 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. Required. - :vartype maximum: str - :ivar default: 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. - Required. - :vartype default: str - """ - - _validation = { - "minimum": {"required": True}, - "maximum": {"required": True}, - "default": {"required": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "str"}, - "maximum": {"key": "maximum", "type": "str"}, - "default": {"key": "default", "type": "str"}, - } - - def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs: Any) -> None: - """ - :keyword minimum: the minimum number of instances for the resource. Required. - :paramtype minimum: str - :keyword maximum: 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. Required. - :paramtype maximum: str - :keyword default: 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. - Required. - :paramtype default: str - """ - super().__init__(**kwargs) - self.minimum = minimum - self.maximum = maximum - self.default = default - - -class ScaleRule(_serialization.Model): - """A rule that provide the triggers and parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar metric_trigger: the trigger that results in a scaling action. Required. - :vartype metric_trigger: ~azure.mgmt.monitor.v2015_04_01.models.MetricTrigger - :ivar scale_action: the parameters for the scaling action. Required. - :vartype scale_action: ~azure.mgmt.monitor.v2015_04_01.models.ScaleAction - """ - - _validation = { - "metric_trigger": {"required": True}, - "scale_action": {"required": True}, - } - - _attribute_map = { - "metric_trigger": {"key": "metricTrigger", "type": "MetricTrigger"}, - "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, - } - - def __init__( - self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs: Any - ) -> None: - """ - :keyword metric_trigger: the trigger that results in a scaling action. Required. - :paramtype metric_trigger: ~azure.mgmt.monitor.v2015_04_01.models.MetricTrigger - :keyword scale_action: the parameters for the scaling action. Required. - :paramtype scale_action: ~azure.mgmt.monitor.v2015_04_01.models.ScaleAction - """ - super().__init__(**kwargs) - self.metric_trigger = metric_trigger - self.scale_action = scale_action - - -class ScaleRuleMetricDimension(_serialization.Model): - """Specifies an auto scale rule metric dimension. - - All required parameters must be populated in order to send to Azure. - - :ivar dimension_name: Name of the dimension. Required. - :vartype dimension_name: str - :ivar operator: 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. Required. - Known values are: "Equals" and "NotEquals". - :vartype operator: str or - ~azure.mgmt.monitor.v2015_04_01.models.ScaleRuleMetricDimensionOperationType - :ivar values: list of dimension values. For example: ["App1","App2"]. Required. - :vartype values: list[str] - """ - - _validation = { - "dimension_name": {"required": True}, - "operator": {"required": True}, - "values": {"required": True}, - } - - _attribute_map = { - "dimension_name": {"key": "DimensionName", "type": "str"}, - "operator": {"key": "Operator", "type": "str"}, - "values": {"key": "Values", "type": "[str]"}, - } - - def __init__( - self, - *, - dimension_name: str, - operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], - values: List[str], - **kwargs: Any - ) -> None: - """ - :keyword dimension_name: Name of the dimension. Required. - :paramtype dimension_name: str - :keyword operator: 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. - Required. Known values are: "Equals" and "NotEquals". - :paramtype operator: str or - ~azure.mgmt.monitor.v2015_04_01.models.ScaleRuleMetricDimensionOperationType - :keyword values: list of dimension values. For example: ["App1","App2"]. Required. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.dimension_name = dimension_name - self.operator = operator - self.values = values - - -class SenderAuthorization(_serialization.Model): - """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'. - - :ivar action: the permissible actions. For instance: microsoft.support/supporttickets/write. - :vartype action: str - :ivar role: the role of the user. For instance: Subscription Admin. - :vartype role: str - :ivar scope: the scope. - :vartype scope: str - """ - - _attribute_map = { - "action": {"key": "action", "type": "str"}, - "role": {"key": "role", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - } - - def __init__( - self, *, action: Optional[str] = None, role: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword action: the permissible actions. For instance: microsoft.support/supporttickets/write. - :paramtype action: str - :keyword role: the role of the user. For instance: Subscription Admin. - :paramtype role: str - :keyword scope: the scope. - :paramtype scope: str - """ - super().__init__(**kwargs) - self.action = action - self.role = role - self.scope = scope - - -class ThresholdRuleCondition(RuleCondition): - """A rule condition based on a metric crossing a threshold. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - :ivar operator: the operator used to compare the data and the threshold. Required. Known values - are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2015_04_01.models.ConditionOperator - :ivar threshold: the threshold value that activates the alert. Required. - :vartype threshold: float - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - :ivar time_aggregation: the time aggregation operator. How the data that are collected should - be combined over time. The default value is the PrimaryAggregationType of the Metric. Known - values are: "Average", "Minimum", "Maximum", "Total", and "Last". - :vartype time_aggregation: str or - ~azure.mgmt.monitor.v2015_04_01.models.TimeAggregationOperator - """ - - _validation = { - "odata_type": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "window_size": {"key": "windowSize", "type": "duration"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - } - - def __init__( - self, - *, - operator: Union[str, "_models.ConditionOperator"], - threshold: float, - data_source: Optional["_models.RuleDataSource"] = None, - window_size: Optional[datetime.timedelta] = None, - time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_04_01.models.RuleDataSource - :keyword operator: the operator used to compare the data and the threshold. Required. Known - values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2015_04_01.models.ConditionOperator - :keyword threshold: the threshold value that activates the alert. Required. - :paramtype threshold: float - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - :keyword time_aggregation: the time aggregation operator. How the data that are collected - should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Known values are: "Average", "Minimum", "Maximum", "Total", and "Last". - :paramtype time_aggregation: str or - ~azure.mgmt.monitor.v2015_04_01.models.TimeAggregationOperator - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" - self.operator = operator - self.threshold = threshold - self.window_size = window_size - self.time_aggregation = time_aggregation - - -class TimeWindow(_serialization.Model): - """A specific date-time for the profile. - - All required parameters must be populated in order to send to Azure. - - :ivar time_zone: 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. - :vartype time_zone: str - :ivar start: the start time for the profile in ISO 8601 format. Required. - :vartype start: ~datetime.datetime - :ivar end: the end time for the profile in ISO 8601 format. Required. - :vartype end: ~datetime.datetime - """ - - _validation = { - "start": {"required": True}, - "end": {"required": True}, - } - - _attribute_map = { - "time_zone": {"key": "timeZone", "type": "str"}, - "start": {"key": "start", "type": "iso-8601"}, - "end": {"key": "end", "type": "iso-8601"}, - } - - def __init__( - self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword time_zone: 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. - :paramtype time_zone: str - :keyword start: the start time for the profile in ISO 8601 format. Required. - :paramtype start: ~datetime.datetime - :keyword end: the end time for the profile in ISO 8601 format. Required. - :paramtype end: ~datetime.datetime - """ - super().__init__(**kwargs) - self.time_zone = time_zone - self.start = start - self.end = end - - -class WebhookNotification(_serialization.Model): - """Webhook notification of an autoscale event. - - :ivar service_uri: the service address to receive the notification. - :vartype service_uri: str - :ivar properties: a property bag of settings. This value can be empty. - :vartype properties: dict[str, str] - """ - - _attribute_map = { - "service_uri": {"key": "serviceUri", "type": "str"}, - "properties": {"key": "properties", "type": "{str}"}, - } - - def __init__( - self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword service_uri: the service address to receive the notification. - :paramtype service_uri: str - :keyword properties: a property bag of settings. This value can be empty. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.service_uri = service_uri - self.properties = properties diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py deleted file mode 100644 index c8326c1a02460..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the operator that is used to compare the metric data and the threshold.""" - - EQUALS = "Equals" - NOT_EQUALS = "NotEquals" - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operators allowed in the rule condition.""" - - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class EventLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the event level.""" - - CRITICAL = "Critical" - ERROR = "Error" - WARNING = "Warning" - INFORMATIONAL = "Informational" - VERBOSE = "Verbose" - - -class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the metric statistic type. How the metrics from multiple instances are combined.""" - - AVERAGE = "Average" - MIN = "Min" - MAX = "Max" - SUM = "Sum" - COUNT = "Count" - - -class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - NONE = "None" - SECOND = "Second" - MINUTE = "Minute" - HOUR = "Hour" - DAY = "Day" - WEEK = "Week" - MONTH = "Month" - YEAR = "Year" - - -class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the scale direction. Whether the scaling action increases or decreases the number of instances.""" - - NONE = "None" - INCREASE = "Increase" - DECREASE = "Decrease" - - -class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - EQUALS = "Equals" - NOT_EQUALS = "NotEquals" - - -class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the type of action that should occur when the scale rule fires.""" - - CHANGE_COUNT = "ChangeCount" - PERCENT_CHANGE_COUNT = "PercentChangeCount" - EXACT_COUNT = "ExactCount" - SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" - - -class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation operators allowed in a rule.""" - - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - LAST = "Last" - - -class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """time aggregation type. How the data that is collected should be combined over time. The default - value is Average. - """ - - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - COUNT = "Count" - LAST = "Last" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py deleted file mode 100644 index c3fc4cfffbbea..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._activity_logs_operations import ActivityLogsOperations -from ._autoscale_settings_operations import AutoscaleSettingsOperations -from ._event_categories_operations import EventCategoriesOperations -from ._operations import Operations -from ._tenant_activity_logs_operations import TenantActivityLogsOperations -from ._alert_rules_operations import AlertRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivityLogsOperations", - "AutoscaleSettingsOperations", - "EventCategoriesOperations", - "Operations", - "TenantActivityLogsOperations", - "AlertRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py deleted file mode 100644 index 41448270c8363..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py +++ /dev/null @@ -1,182 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - subscription_id: str, *, filter: str, select: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActivityLogsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.MonitorManagementClient`'s - :attr:`activity_logs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> Iterable["_models.EventData"]: - """Provides the list of records from the activity logs. - - :param filter: Reduces the set of data collected.:code:`
`This argument is required and it - also requires at least the start date/time.:code:`
`The **$filter** argument is very - restricted and allows only the following patterns.:code:`
`- *List events for a resource - group*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.:code:`
`- *List - events for resource*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and - eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.:code:`
`- - *List events for a subscription in a time range*\ : $filter=eventTimestamp ge - '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - '2014-07-20T04:36:37.6407898Z'.:code:`
`- *List events for a resource provider*\ : - $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'.:code:`
`- - *List events for a correlation Id*\ : $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' - and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq - 'correlationID'.:code:`
`:code:`
`\ **NOTE**\ : No other syntax is allowed. Required. - :type filter: str - :param select: Used to fetch events with only the given properties.:code:`
`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*. Default - value is None. - :type select: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventData or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_04_01.models.EventData] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - select=select, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EventDataCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py deleted file mode 100644 index 4d80bab51be19..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py +++ /dev/null @@ -1,804 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AlertRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.MonitorManagementClient`'s - :attr:`alert_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.AlertRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - AlertRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AlertRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: - """Gets a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a - AlertRuleResourcePatch type or a IO type. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_rules_resource, (IO, bytes)): - _content = alert_rules_resource - else: - _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py deleted file mode 100644 index 9f69f7172c888..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py +++ /dev/null @@ -1,822 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AutoscaleSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.MonitorManagementClient`'s - :attr:`autoscale_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: _models.AutoscaleSettingResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: Union[_models.AutoscaleSettingResource, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AutoscaleSettingResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> None: - """Deletes and autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def get( - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Gets an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @overload - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a - AutoscaleSettingResourcePatch type or a IO type. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(autoscale_setting_resource, (IO, bytes)): - _content = autoscale_setting_resource - else: - _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_04_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py deleted file mode 100644 index a09308f984919..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py +++ /dev/null @@ -1,145 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventcategories") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class EventCategoriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.MonitorManagementClient`'s - :attr:`event_categories` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.LocalizableString"]: - """Get the list of available event categories supported in the Activity Logs - Service.:code:`
`The current list includes the following: Administrative, Security, - ServiceHealth, Alert, Recommendation, Policy. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocalizableString or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_04_01.models.LocalizableString] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.EventCategoryCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EventCategoryCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py deleted file mode 100644 index 05ac4a16b7d47..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py +++ /dev/null @@ -1,125 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.MonitorManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.OperationListResult: - """Lists all of the available operations from Microsoft.Insights provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_04_01.models.OperationListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py deleted file mode 100644 index 60dea5639b33b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py +++ /dev/null @@ -1,180 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(*, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventtypes/management/values") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class TenantActivityLogsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_04_01.MonitorManagementClient`'s - :attr:`tenant_activity_logs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.EventData"]: - """Gets the Activity Logs for the Tenant.:code:`
`Everything that is applicable to the API to - get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, - etc.).:code:`
`One thing to point out here is that this API does *not* retrieve the logs at - the individual subscription of the tenant but only surfaces the logs that were generated at the - tenant level. - - :param filter: Reduces the set of data collected. :code:`
`The **$filter** is very - restricted and allows only the following patterns.:code:`
`- List events for a resource - group: $filter=eventTimestamp ge ':code:``' and eventTimestamp le ':code:``' and eventChannels eq 'Admin, Operation' and resourceGroupName eq - ':code:``'.:code:`
`- List events for resource: $filter=eventTimestamp ge - ':code:``' and eventTimestamp le ':code:``' and eventChannels eq 'Admin, - Operation' and resourceUri eq ':code:``'.:code:`
`- List events for a - subscription: $filter=eventTimestamp ge ':code:``' and eventTimestamp le - ':code:``' and eventChannels eq 'Admin, Operation'.:code:`
`- List events for a - resource provider: $filter=eventTimestamp ge ':code:``' and eventTimestamp le - ':code:``' and eventChannels eq 'Admin, Operation' and resourceProvider eq - ':code:``'.:code:`
`- List events for a correlation Id: - api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and - eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - correlationId eq ':code:``'.:code:`
`\ **NOTE**\ : No other syntax is - allowed. Default value is None. - :type filter: str - :param select: Used to fetch events with only the given properties.:code:`
`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*. Default - value is None. - :type select: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventData or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_04_01.models.EventData] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) - cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - select=select, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EventDataCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py deleted file mode 100644 index 84225ab1970a1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json deleted file mode 100644 index 9a7ac678d6b99..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2015-07-01", - "total_api_version_list": ["2014-04-01", "2015-07-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "service_diagnostic_settings": "ServiceDiagnosticSettingsOperations", - "metric_definitions": "MetricDefinitionsOperations", - "alert_rules": "AlertRulesOperations", - "operations": "Operations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py deleted file mode 100644 index f731fd10450f2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - AlertRulesOperations, - MetricDefinitionsOperations, - Operations, - ServiceDiagnosticSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: - azure.mgmt.monitor.v2015_07_01.operations.ServiceDiagnosticSettingsOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2015_07_01.operations.MetricDefinitionsOperations - :ivar alert_rules: AlertRulesOperations operations - :vartype alert_rules: azure.mgmt.monitor.v2015_07_01.operations.AlertRulesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.monitor.v2015_07_01.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py deleted file mode 100644 index ff77a05cbd874..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py deleted file mode 100644 index 34c68d3a46a36..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - AlertRulesOperations, - MetricDefinitionsOperations, - Operations, - ServiceDiagnosticSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: - azure.mgmt.monitor.v2015_07_01.aio.operations.ServiceDiagnosticSettingsOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2015_07_01.aio.operations.MetricDefinitionsOperations - :ivar alert_rules: AlertRulesOperations operations - :vartype alert_rules: azure.mgmt.monitor.v2015_07_01.aio.operations.AlertRulesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.monitor.v2015_07_01.aio.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py deleted file mode 100644 index acff6da37ac2d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._alert_rules_operations import AlertRulesOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ServiceDiagnosticSettingsOperations", - "MetricDefinitionsOperations", - "AlertRulesOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py deleted file mode 100644 index 01f85a07da2c4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py +++ /dev/null @@ -1,627 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._alert_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AlertRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.aio.MonitorManagementClient`'s - :attr:`alert_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.AlertRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - AlertRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AlertRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: - """Gets a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a - AlertRuleResourcePatch type or a IO type. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_rules_resource, (IO, bytes)): - _content = alert_rules_resource - else: - _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py deleted file mode 100644 index 51928f7de0118..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,135 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_definitions_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.aio.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param filter: Reduces the set of data collected by retrieving particular metric definitions - from all the definitions available for the resource.:code:`
`For example, to get just the - definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% - Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq - :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2015_07_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py deleted file mode 100644 index 05cc5136db3f5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.aio.MonitorManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.OperationListResult: - """Lists all of the available operations from Microsoft.Insights provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.OperationListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py deleted file mode 100644 index a7d0a3178b8fa..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py +++ /dev/null @@ -1,226 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._service_diagnostic_settings_operations import build_create_or_update_request, build_get_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ServiceDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.aio.MonitorManagementClient`'s - :attr:`service_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} - - @overload - async def create_or_update( - self, - resource_uri: str, - parameters: _models.ServiceDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a - ServiceDiagnosticSettingsResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py deleted file mode 100644 index 20372e4e30d82..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AlertRuleResource -from ._models_py3 import AlertRuleResourceCollection -from ._models_py3 import AlertRuleResourcePatch -from ._models_py3 import DimensionProperties -from ._models_py3 import ErrorContract -from ._models_py3 import ErrorResponse -from ._models_py3 import LocalizableString -from ._models_py3 import LocationThresholdRuleCondition -from ._models_py3 import LogSettings -from ._models_py3 import LogSpecification -from ._models_py3 import ManagementEventAggregationCondition -from ._models_py3 import ManagementEventRuleCondition -from ._models_py3 import MetricAvailability -from ._models_py3 import MetricAvailabilityLocation -from ._models_py3 import MetricDefinition -from ._models_py3 import MetricDefinitionCollection -from ._models_py3 import MetricSettings -from ._models_py3 import MetricSpecification -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Resource -from ._models_py3 import RetentionPolicy -from ._models_py3 import RuleAction -from ._models_py3 import RuleCondition -from ._models_py3 import RuleDataSource -from ._models_py3 import RuleEmailAction -from ._models_py3 import RuleManagementEventClaimsDataSource -from ._models_py3 import RuleManagementEventDataSource -from ._models_py3 import RuleMetricDataSource -from ._models_py3 import RuleWebhookAction -from ._models_py3 import ServiceDiagnosticSettingsResource -from ._models_py3 import ServiceSpecification -from ._models_py3 import TableInfoEntry -from ._models_py3 import ThresholdRuleCondition - -from ._monitor_management_client_enums import AggregationType -from ._monitor_management_client_enums import ConditionOperator -from ._monitor_management_client_enums import TimeAggregationOperator -from ._monitor_management_client_enums import Unit -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertRuleResource", - "AlertRuleResourceCollection", - "AlertRuleResourcePatch", - "DimensionProperties", - "ErrorContract", - "ErrorResponse", - "LocalizableString", - "LocationThresholdRuleCondition", - "LogSettings", - "LogSpecification", - "ManagementEventAggregationCondition", - "ManagementEventRuleCondition", - "MetricAvailability", - "MetricAvailabilityLocation", - "MetricDefinition", - "MetricDefinitionCollection", - "MetricSettings", - "MetricSpecification", - "Operation", - "OperationDisplay", - "OperationListResult", - "Resource", - "RetentionPolicy", - "RuleAction", - "RuleCondition", - "RuleDataSource", - "RuleEmailAction", - "RuleManagementEventClaimsDataSource", - "RuleManagementEventDataSource", - "RuleMetricDataSource", - "RuleWebhookAction", - "ServiceDiagnosticSettingsResource", - "ServiceSpecification", - "TableInfoEntry", - "ThresholdRuleCondition", - "AggregationType", - "ConditionOperator", - "TimeAggregationOperator", - "Unit", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py deleted file mode 100644 index 3f108a3518d50..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py +++ /dev/null @@ -1,1962 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class AlertRuleResource(Resource): # pylint: disable=too-many-instance-attributes - """The alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar name_properties_name: the name of the alert rule. Required. - :vartype name_properties_name: str - :ivar description: the description of the alert rule that will be included in the alert email. - :vartype description: str - :ivar provisioning_state: the provisioning state. - :vartype provisioning_state: str - :ivar is_enabled: the flag that indicates whether the alert rule is enabled. Required. - :vartype is_enabled: bool - :ivar condition: the condition that results in the alert rule being activated. Required. - :vartype condition: ~azure.mgmt.monitor.v2015_07_01.models.RuleCondition - :ivar action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :vartype action: ~azure.mgmt.monitor.v2015_07_01.models.RuleAction - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2015_07_01.models.RuleAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "name_properties_name": {"required": True}, - "is_enabled": {"required": True}, - "condition": {"required": True}, - "last_updated_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "RuleCondition"}, - "action": {"key": "properties.action", "type": "RuleAction"}, - "actions": {"key": "properties.actions", "type": "[RuleAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - location: str, - name_properties_name: str, - is_enabled: bool, - condition: "_models.RuleCondition", - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - provisioning_state: Optional[str] = None, - action: Optional["_models.RuleAction"] = None, - actions: Optional[List["_models.RuleAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword name_properties_name: the name of the alert rule. Required. - :paramtype name_properties_name: str - :keyword description: the description of the alert rule that will be included in the alert - email. - :paramtype description: str - :keyword provisioning_state: the provisioning state. - :paramtype provisioning_state: str - :keyword is_enabled: the flag that indicates whether the alert rule is enabled. Required. - :paramtype is_enabled: bool - :keyword condition: the condition that results in the alert rule being activated. Required. - :paramtype condition: ~azure.mgmt.monitor.v2015_07_01.models.RuleCondition - :keyword action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :paramtype action: ~azure.mgmt.monitor.v2015_07_01.models.RuleAction - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2015_07_01.models.RuleAction] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.name_properties_name = name_properties_name - self.description = description - self.provisioning_state = provisioning_state - self.is_enabled = is_enabled - self.condition = condition - self.action = action - self.actions = actions - self.last_updated_time = None - - -class AlertRuleResourceCollection(_serialization.Model): - """Represents a collection of alert rule resources. - - :ivar value: the values for the alert rule resources. - :vartype value: list[~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AlertRuleResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: the values for the alert rule resources. - :paramtype value: list[~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource] - """ - super().__init__(**kwargs) - self.value = value - - -class AlertRuleResourcePatch(_serialization.Model): - """The alert rule object for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar name: the name of the alert rule. - :vartype name: str - :ivar description: the description of the alert rule that will be included in the alert email. - :vartype description: str - :ivar provisioning_state: the provisioning state. - :vartype provisioning_state: str - :ivar is_enabled: the flag that indicates whether the alert rule is enabled. - :vartype is_enabled: bool - :ivar condition: the condition that results in the alert rule being activated. - :vartype condition: ~azure.mgmt.monitor.v2015_07_01.models.RuleCondition - :ivar action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :vartype action: ~azure.mgmt.monitor.v2015_07_01.models.RuleAction - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2015_07_01.models.RuleAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - """ - - _validation = { - "last_updated_time": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "name": {"key": "properties.name", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "RuleCondition"}, - "action": {"key": "properties.action", "type": "RuleAction"}, - "actions": {"key": "properties.actions", "type": "[RuleAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - name: Optional[str] = None, - description: Optional[str] = None, - provisioning_state: Optional[str] = None, - is_enabled: Optional[bool] = None, - condition: Optional["_models.RuleCondition"] = None, - action: Optional["_models.RuleAction"] = None, - actions: Optional[List["_models.RuleAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword name: the name of the alert rule. - :paramtype name: str - :keyword description: the description of the alert rule that will be included in the alert - email. - :paramtype description: str - :keyword provisioning_state: the provisioning state. - :paramtype provisioning_state: str - :keyword is_enabled: the flag that indicates whether the alert rule is enabled. - :paramtype is_enabled: bool - :keyword condition: the condition that results in the alert rule being activated. - :paramtype condition: ~azure.mgmt.monitor.v2015_07_01.models.RuleCondition - :keyword action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :paramtype action: ~azure.mgmt.monitor.v2015_07_01.models.RuleAction - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2015_07_01.models.RuleAction] - """ - super().__init__(**kwargs) - self.tags = tags - self.name = name - self.description = description - self.provisioning_state = provisioning_state - self.is_enabled = is_enabled - self.condition = condition - self.action = action - self.actions = actions - self.last_updated_time = None - - -class DimensionProperties(_serialization.Model): - """Type of operation: get, read, delete, etc. - - :ivar name: Name of dimension. - :vartype name: str - :ivar display_name: Display name of dimension. - :vartype display_name: str - :ivar to_be_exported_for_shoebox: Legacy usage, should not set. - :vartype to_be_exported_for_shoebox: bool - :ivar is_hidden: When set, the dimension is hidden from the customer, used in conjunction with - the defaultDimensionValues field below. - :vartype is_hidden: bool - :ivar default_dimension_values: Default dimension value to be sent down for the hidden - dimension during query. - :vartype default_dimension_values: JSON - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, - "is_hidden": {"key": "isHidden", "type": "bool"}, - "default_dimension_values": {"key": "defaultDimensionValues", "type": "object"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - to_be_exported_for_shoebox: Optional[bool] = None, - is_hidden: Optional[bool] = None, - default_dimension_values: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of dimension. - :paramtype name: str - :keyword display_name: Display name of dimension. - :paramtype display_name: str - :keyword to_be_exported_for_shoebox: Legacy usage, should not set. - :paramtype to_be_exported_for_shoebox: bool - :keyword is_hidden: When set, the dimension is hidden from the customer, used in conjunction - with the defaultDimensionValues field below. - :paramtype is_hidden: bool - :keyword default_dimension_values: Default dimension value to be sent down for the hidden - dimension during query. - :paramtype default_dimension_values: JSON - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.to_be_exported_for_shoebox = to_be_exported_for_shoebox - self.is_hidden = is_hidden - self.default_dimension_values = default_dimension_values - - -class ErrorContract(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2015_07_01.models.ErrorResponse - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponse"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2015_07_01.models.ErrorResponse - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class LocalizableString(_serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the invariant value. Required. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: the invariant value. Required. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class RuleCondition(_serialization.Model): - """The condition that results in the alert rule being activated. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": "LocationThresholdRuleCondition", - "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": "ManagementEventRuleCondition", - "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": "ThresholdRuleCondition", - } - } - - def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs: Any) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - self.data_source = data_source - - -class LocationThresholdRuleCondition(RuleCondition): - """A rule condition based on a certain number of locations failing. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - :ivar failed_location_count: the number of locations that must fail to activate the alert. - Required. - :vartype failed_location_count: int - """ - - _validation = { - "odata_type": {"required": True}, - "failed_location_count": {"required": True, "minimum": 0}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "window_size": {"key": "windowSize", "type": "duration"}, - "failed_location_count": {"key": "failedLocationCount", "type": "int"}, - } - - def __init__( - self, - *, - failed_location_count: int, - data_source: Optional["_models.RuleDataSource"] = None, - window_size: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - :keyword failed_location_count: the number of locations that must fail to activate the alert. - Required. - :paramtype failed_location_count: int - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" - self.window_size = window_size - self.failed_location_count = failed_location_count - - -class LogSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: 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. - :vartype category: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this log. - :vartype retention_policy: ~azure.mgmt.monitor.v2015_07_01.models.RetentionPolicy - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - enabled: bool, - category: Optional[str] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword category: 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. - :paramtype category: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this log. - :paramtype retention_policy: ~azure.mgmt.monitor.v2015_07_01.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.category = category - self.enabled = enabled - self.retention_policy = retention_policy - - -class LogSpecification(_serialization.Model): - """Log specification of operation. - - :ivar name: Name of log specification. - :vartype name: str - :ivar display_name: Display name of log specification. - :vartype display_name: str - :ivar blob_duration: Blob duration of specification. - :vartype blob_duration: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "blob_duration": {"key": "blobDuration", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - blob_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of log specification. - :paramtype name: str - :keyword display_name: Display name of log specification. - :paramtype display_name: str - :keyword blob_duration: Blob duration of specification. - :paramtype blob_duration: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.blob_duration = blob_duration - - -class ManagementEventAggregationCondition(_serialization.Model): - """How the data that is collected should be combined over time. - - :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2015_07_01.models.ConditionOperator - :ivar threshold: The threshold value that activates the alert. - :vartype threshold: float - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - """ - - _attribute_map = { - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "window_size": {"key": "windowSize", "type": "duration"}, - } - - def __init__( - self, - *, - operator: Optional[Union[str, "_models.ConditionOperator"]] = None, - threshold: Optional[float] = None, - window_size: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword operator: the condition operator. Known values are: "GreaterThan", - "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2015_07_01.models.ConditionOperator - :keyword threshold: The threshold value that activates the alert. - :paramtype threshold: float - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.operator = operator - self.threshold = threshold - self.window_size = window_size - - -class ManagementEventRuleCondition(RuleCondition): - """A management event rule condition. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - :ivar aggregation: 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. - :vartype aggregation: - ~azure.mgmt.monitor.v2015_07_01.models.ManagementEventAggregationCondition - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "aggregation": {"key": "aggregation", "type": "ManagementEventAggregationCondition"}, - } - - def __init__( - self, - *, - data_source: Optional["_models.RuleDataSource"] = None, - aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - :keyword aggregation: 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. - :paramtype aggregation: - ~azure.mgmt.monitor.v2015_07_01.models.ManagementEventAggregationCondition - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" - self.aggregation = aggregation - - -class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the - retention period for that time grain. - - :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed - as a duration 'PT1M', 'P1D', etc. - :vartype time_grain: ~datetime.timedelta - :ivar retention: the retention period for the metric at the specified timegrain. Expressed as - a duration 'PT1M', 'P1D', etc. - :vartype retention: ~datetime.timedelta - :ivar location: Info about where the metric data is stored. - :vartype location: ~azure.mgmt.monitor.v2015_07_01.models.MetricAvailabilityLocation - """ - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "retention": {"key": "retention", "type": "duration"}, - "location": {"key": "location", "type": "MetricAvailabilityLocation"}, - } - - def __init__( - self, - *, - time_grain: Optional[datetime.timedelta] = None, - retention: Optional[datetime.timedelta] = None, - location: Optional["_models.MetricAvailabilityLocation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the time grain specifies the aggregation interval for the metric. - Expressed as a duration 'PT1M', 'P1D', etc. - :paramtype time_grain: ~datetime.timedelta - :keyword retention: the retention period for the metric at the specified timegrain. Expressed - as a duration 'PT1M', 'P1D', etc. - :paramtype retention: ~datetime.timedelta - :keyword location: Info about where the metric data is stored. - :paramtype location: ~azure.mgmt.monitor.v2015_07_01.models.MetricAvailabilityLocation - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.retention = retention - self.location = location - - -class MetricAvailabilityLocation(_serialization.Model): - """Info about where the metric data is stored. - - :ivar table_endpoint: The url for the storage account. - :vartype table_endpoint: str - :ivar table_info: Info about the storage tables storing this resources metrics. - :vartype table_info: list[~azure.mgmt.monitor.v2015_07_01.models.TableInfoEntry] - :ivar partition_key: partition key in the table where the metrics for this resource are stored. - :vartype partition_key: str - """ - - _attribute_map = { - "table_endpoint": {"key": "tableEndpoint", "type": "str"}, - "table_info": {"key": "tableInfo", "type": "[TableInfoEntry]"}, - "partition_key": {"key": "partitionKey", "type": "str"}, - } - - def __init__( - self, - *, - table_endpoint: Optional[str] = None, - table_info: Optional[List["_models.TableInfoEntry"]] = None, - partition_key: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword table_endpoint: The url for the storage account. - :paramtype table_endpoint: str - :keyword table_info: Info about the storage tables storing this resources metrics. - :paramtype table_info: list[~azure.mgmt.monitor.v2015_07_01.models.TableInfoEntry] - :keyword partition_key: partition key in the table where the metrics for this resource are - stored. - :paramtype partition_key: str - """ - super().__init__(**kwargs) - self.table_endpoint = table_endpoint - self.table_info = table_info - self.partition_key = partition_key - - -class MetricDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Metric definition class specifies the metadata for a metric. - - :ivar resource_id: The resource identifier of the resource that emitted the metric. - :vartype resource_id: str - :ivar resource_uri: The resource identifier of the resource that emitted the metric. - :vartype resource_uri: str - :ivar name: the name and the display name of the metric, i.e. it is a localizable string. - :vartype name: ~azure.mgmt.monitor.v2015_07_01.models.LocalizableString - :ivar category: The category of this metric. - :vartype category: str - :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", and "MilliSeconds". - :vartype unit: str or ~azure.mgmt.monitor.v2015_07_01.models.Unit - :ivar start_time: Start time of the metadata request timespan. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the metadata request timespan. - :vartype end_time: ~datetime.datetime - :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :vartype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2015_07_01.models.AggregationType - :ivar supported_aggregation_types: List of all aggregations that are applicable for this - metric. - :vartype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2015_07_01.models.AggregationType] - :ivar metric_availabilities: the collection of what aggregation intervals are available to be - queried. - :vartype metric_availabilities: list[~azure.mgmt.monitor.v2015_07_01.models.MetricAvailability] - :ivar id: the resource identifier of the metric definition. - :vartype id: str - """ - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "category": {"key": "category", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, - "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, - "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, - *, - resource_id: Optional[str] = None, - resource_uri: Optional[str] = None, - name: Optional["_models.LocalizableString"] = None, - category: Optional[str] = None, - unit: Optional[Union[str, "_models.Unit"]] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, - supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, - metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword resource_id: The resource identifier of the resource that emitted the metric. - :paramtype resource_id: str - :keyword resource_uri: The resource identifier of the resource that emitted the metric. - :paramtype resource_uri: str - :keyword name: the name and the display name of the metric, i.e. it is a localizable string. - :paramtype name: ~azure.mgmt.monitor.v2015_07_01.models.LocalizableString - :keyword category: The category of this metric. - :paramtype category: str - :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", and "MilliSeconds". - :paramtype unit: str or ~azure.mgmt.monitor.v2015_07_01.models.Unit - :keyword start_time: Start time of the metadata request timespan. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time of the metadata request timespan. - :paramtype end_time: ~datetime.datetime - :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :paramtype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2015_07_01.models.AggregationType - :keyword supported_aggregation_types: List of all aggregations that are applicable for this - metric. - :paramtype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2015_07_01.models.AggregationType] - :keyword metric_availabilities: the collection of what aggregation intervals are available to - be queried. - :paramtype metric_availabilities: - list[~azure.mgmt.monitor.v2015_07_01.models.MetricAvailability] - :keyword id: the resource identifier of the metric definition. - :paramtype id: str - """ - super().__init__(**kwargs) - self.resource_id = resource_id - self.resource_uri = resource_uri - self.name = name - self.category = category - self.unit = unit - self.start_time = start_time - self.end_time = end_time - self.primary_aggregation_type = primary_aggregation_type - self.supported_aggregation_types = supported_aggregation_types - self.metric_availabilities = metric_availabilities - self.id = id - - -class MetricDefinitionCollection(_serialization.Model): - """Represents collection of metric definitions. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id for these metric definitions. - :vartype id: str - :ivar value: the values for the metric definitions. Required. - :vartype value: list[~azure.mgmt.monitor.v2015_07_01.models.MetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "value": {"key": "value", "type": "[MetricDefinition]"}, - } - - def __init__( - self, - *, - value: List["_models.MetricDefinition"], - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword id: Resource Id for these metric definitions. - :paramtype id: str - :keyword value: the values for the metric definitions. Required. - :paramtype value: list[~azure.mgmt.monitor.v2015_07_01.models.MetricDefinition] - """ - super().__init__(**kwargs) - self.id = id - self.value = value - - -class MetricSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - All required parameters must be populated in order to send to Azure. - - :ivar time_grain: the timegrain of the metric in ISO8601 format. Required. - :vartype time_grain: ~datetime.timedelta - :ivar enabled: a value indicating whether this timegrain is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this timegrain. - :vartype retention_policy: ~azure.mgmt.monitor.v2015_07_01.models.RetentionPolicy - """ - - _validation = { - "time_grain": {"required": True}, - "enabled": {"required": True}, - } - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - time_grain: datetime.timedelta, - enabled: bool, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the timegrain of the metric in ISO8601 format. Required. - :paramtype time_grain: ~datetime.timedelta - :keyword enabled: a value indicating whether this timegrain is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this timegrain. - :paramtype retention_policy: ~azure.mgmt.monitor.v2015_07_01.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.enabled = enabled - self.retention_policy = retention_policy - - -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Metric specification of operation. - - :ivar name: The name of the metric. - :vartype name: str - :ivar display_name: Display name of the metric. - :vartype display_name: str - :ivar display_description: Display description of the metric. - :vartype display_description: str - :ivar unit: The metric unit. Possible values include: - Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. - :vartype unit: str - :ivar aggregation_type: The default metric aggregation type. Possible values include: - Total,Average,Maximum,Minimum,Count. - :vartype aggregation_type: str - :ivar supported_aggregation_types: The supported aggregation types for the metrics. - :vartype supported_aggregation_types: list[str] - :ivar supported_time_grain_types: The supported time grain types for the metrics. - :vartype supported_time_grain_types: list[str] - :ivar availabilities: The supported time grain types for the metrics. - :vartype availabilities: list[str] - :ivar lock_aggregation_type: The metric lock aggregation type. - :vartype lock_aggregation_type: str - :ivar category: Category or type of metric. - :vartype category: str - :ivar dimensions: The dimensions of metric. - :vartype dimensions: list[~azure.mgmt.monitor.v2015_07_01.models.DimensionProperties] - :ivar fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. - :vartype fill_gap_with_zero: bool - :ivar internal_metric_name: The internal metric name. - :vartype internal_metric_name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "aggregation_type": {"key": "aggregationType", "type": "str"}, - "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, - "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, - "availabilities": {"key": "availabilities", "type": "[str]"}, - "lock_aggregation_type": {"key": "lockAggregationType", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[DimensionProperties]"}, - "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, - "internal_metric_name": {"key": "internalMetricName", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - display_description: Optional[str] = None, - unit: Optional[str] = None, - aggregation_type: Optional[str] = None, - supported_aggregation_types: Optional[List[str]] = None, - supported_time_grain_types: Optional[List[str]] = None, - availabilities: Optional[List[str]] = None, - lock_aggregation_type: Optional[str] = None, - category: Optional[str] = None, - dimensions: Optional[List["_models.DimensionProperties"]] = None, - fill_gap_with_zero: Optional[bool] = None, - internal_metric_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the metric. - :paramtype name: str - :keyword display_name: Display name of the metric. - :paramtype display_name: str - :keyword display_description: Display description of the metric. - :paramtype display_description: str - :keyword unit: The metric unit. Possible values include: - Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. - :paramtype unit: str - :keyword aggregation_type: The default metric aggregation type. Possible values include: - Total,Average,Maximum,Minimum,Count. - :paramtype aggregation_type: str - :keyword supported_aggregation_types: The supported aggregation types for the metrics. - :paramtype supported_aggregation_types: list[str] - :keyword supported_time_grain_types: The supported time grain types for the metrics. - :paramtype supported_time_grain_types: list[str] - :keyword availabilities: The supported time grain types for the metrics. - :paramtype availabilities: list[str] - :keyword lock_aggregation_type: The metric lock aggregation type. - :paramtype lock_aggregation_type: str - :keyword category: Category or type of metric. - :paramtype category: str - :keyword dimensions: The dimensions of metric. - :paramtype dimensions: list[~azure.mgmt.monitor.v2015_07_01.models.DimensionProperties] - :keyword fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. - :paramtype fill_gap_with_zero: bool - :keyword internal_metric_name: The internal metric name. - :paramtype internal_metric_name: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.display_description = display_description - self.unit = unit - self.aggregation_type = aggregation_type - self.supported_aggregation_types = supported_aggregation_types - self.supported_time_grain_types = supported_time_grain_types - self.availabilities = availabilities - self.lock_aggregation_type = lock_aggregation_type - self.category = category - self.dimensions = dimensions - self.fill_gap_with_zero = fill_gap_with_zero - self.internal_metric_name = internal_metric_name - - -class Operation(_serialization.Model): - """Microsoft Insights API operation definition. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar is_data_action: Property to specify whether the action is a data action. - :vartype is_data_action: bool - :ivar display: Display metadata associated with the operation. - :vartype display: ~azure.mgmt.monitor.v2015_07_01.models.OperationDisplay - :ivar service_specification: One property of operation, include metric specifications. - :vartype service_specification: ~azure.mgmt.monitor.v2015_07_01.models.ServiceSpecification - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - service_specification: Optional["_models.ServiceSpecification"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Operation name: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword is_data_action: Property to specify whether the action is a data action. - :paramtype is_data_action: bool - :keyword display: Display metadata associated with the operation. - :paramtype display: ~azure.mgmt.monitor.v2015_07_01.models.OperationDisplay - :keyword service_specification: One property of operation, include metric specifications. - :paramtype service_specification: ~azure.mgmt.monitor.v2015_07_01.models.ServiceSpecification - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.service_specification = service_specification - - -class OperationDisplay(_serialization.Model): - """Display metadata associated with the operation. - - :ivar publisher: The publisher of this operation. - :vartype publisher: str - :ivar provider: Service provider: Microsoft.Insights. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - :ivar description: The description of the operation. - :vartype description: str - """ - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - publisher: Optional[str] = None, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher: The publisher of this operation. - :paramtype publisher: str - :keyword provider: Service provider: Microsoft.Insights. - :paramtype provider: str - :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :paramtype resource: str - :keyword operation: Operation type: Read, write, delete, etc. - :paramtype operation: str - :keyword description: The description of the operation. - :paramtype description: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationListResult(_serialization.Model): - """Result of the request to list Microsoft.Insights operations. It contains a list of operations - and a URL link to get the next set of results. - - :ivar value: List of operations supported by the Microsoft.Insights provider. - :vartype value: list[~azure.mgmt.monitor.v2015_07_01.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of operations supported by the Microsoft.Insights provider. - :paramtype value: list[~azure.mgmt.monitor.v2015_07_01.models.Operation] - :keyword next_link: URL to get the next set of operation list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RetentionPolicy(_serialization.Model): - """Specifies the retention policy for the log. - - All required parameters must be populated in order to send to Azure. - - :ivar enabled: a value indicating whether the retention policy is enabled. Required. - :vartype enabled: bool - :ivar days: the number of days for the retention in days. A value of 0 will retain the events - indefinitely. Required. - :vartype days: int - """ - - _validation = { - "enabled": {"required": True}, - "days": {"required": True}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "days": {"key": "days", "type": "int"}, - } - - def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: - """ - :keyword enabled: a value indicating whether the retention policy is enabled. Required. - :paramtype enabled: bool - :keyword days: the number of days for the retention in days. A value of 0 will retain the - events indefinitely. Required. - :paramtype days: int - """ - super().__init__(**kwargs) - self.enabled = enabled - self.days = days - - -class RuleAction(_serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is - resolved. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RuleEmailAction, RuleWebhookAction - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": "RuleEmailAction", - "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": "RuleWebhookAction", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - - -class RuleDataSource(_serialization.Model): - """The resource from which the rule collects its data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RuleManagementEventDataSource, RuleMetricDataSource - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": "RuleManagementEventDataSource", - "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": "RuleMetricDataSource", - } - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - self.resource_uri = resource_uri - self.legacy_resource_id = legacy_resource_id - self.resource_location = resource_location - self.metric_namespace = metric_namespace - - -class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is - always RuleEmailAction in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the - service should be notified when the alert is activated. - :vartype send_to_service_owners: bool - :ivar custom_emails: the list of administrator's custom email addresses to notify of the - activation of the alert. - :vartype custom_emails: list[str] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "send_to_service_owners": {"key": "sendToServiceOwners", "type": "bool"}, - "custom_emails": {"key": "customEmails", "type": "[str]"}, - } - - def __init__( - self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :paramtype send_to_service_owners: bool - :keyword custom_emails: the list of administrator's custom email addresses to notify of the - activation of the alert. - :paramtype custom_emails: list[str] - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" - self.send_to_service_owners = send_to_service_owners - self.custom_emails = custom_emails - - -class RuleManagementEventClaimsDataSource(_serialization.Model): - """The claims for a rule management event data source. - - :ivar email_address: the email address. - :vartype email_address: str - """ - - _attribute_map = { - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, email_address: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword email_address: the email address. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.email_address = email_address - - -class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes - """A rule management event data source. The discriminator fields is always - RuleManagementEventDataSource in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - :ivar event_name: the event name. - :vartype event_name: str - :ivar event_source: the event source. - :vartype event_source: str - :ivar level: the level. - :vartype level: str - :ivar operation_name: The name of the operation that should be checked for. If no name is - provided, any operation will match. - :vartype operation_name: str - :ivar resource_group_name: the resource group name. - :vartype resource_group_name: str - :ivar resource_provider_name: the resource provider name. - :vartype resource_provider_name: str - :ivar status: The status of the operation that should be checked for. If no status is provided, - any status will match. - :vartype status: str - :ivar sub_status: the substatus. - :vartype sub_status: str - :ivar claims: the claims. - :vartype claims: ~azure.mgmt.monitor.v2015_07_01.models.RuleManagementEventClaimsDataSource - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "event_name": {"key": "eventName", "type": "str"}, - "event_source": {"key": "eventSource", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "operation_name": {"key": "operationName", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "resource_provider_name": {"key": "resourceProviderName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "sub_status": {"key": "subStatus", "type": "str"}, - "claims": {"key": "claims", "type": "RuleManagementEventClaimsDataSource"}, - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - event_name: Optional[str] = None, - event_source: Optional[str] = None, - level: Optional[str] = None, - operation_name: Optional[str] = None, - resource_group_name: Optional[str] = None, - resource_provider_name: Optional[str] = None, - status: Optional[str] = None, - sub_status: Optional[str] = None, - claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - :keyword event_name: the event name. - :paramtype event_name: str - :keyword event_source: the event source. - :paramtype event_source: str - :keyword level: the level. - :paramtype level: str - :keyword operation_name: The name of the operation that should be checked for. If no name is - provided, any operation will match. - :paramtype operation_name: str - :keyword resource_group_name: the resource group name. - :paramtype resource_group_name: str - :keyword resource_provider_name: the resource provider name. - :paramtype resource_provider_name: str - :keyword status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :paramtype status: str - :keyword sub_status: the substatus. - :paramtype sub_status: str - :keyword claims: the claims. - :paramtype claims: ~azure.mgmt.monitor.v2015_07_01.models.RuleManagementEventClaimsDataSource - """ - super().__init__( - resource_uri=resource_uri, - legacy_resource_id=legacy_resource_id, - resource_location=resource_location, - metric_namespace=metric_namespace, - **kwargs - ) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" - self.event_name = event_name - self.event_source = event_source - self.level = level - self.operation_name = operation_name - self.resource_group_name = resource_group_name - self.resource_provider_name = resource_provider_name - self.status = status - self.sub_status = sub_status - self.claims = claims - - -class RuleMetricDataSource(RuleDataSource): - """A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - :ivar metric_name: the name of the metric that defines what the rule monitors. - :vartype metric_name: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "metric_name": {"key": "metricName", "type": "str"}, - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - metric_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - :keyword metric_name: the name of the metric that defines what the rule monitors. - :paramtype metric_name: str - """ - super().__init__( - resource_uri=resource_uri, - legacy_resource_id=legacy_resource_id, - resource_location=resource_location, - metric_namespace=metric_namespace, - **kwargs - ) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" - self.metric_name = metric_name - - -class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator - is always RuleWebhookAction in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - :ivar service_uri: the service uri to Post the notification when the alert activates or - resolves. - :vartype service_uri: str - :ivar properties: the dictionary of custom properties to include with the post operation. These - data are appended to the webhook payload. - :vartype properties: dict[str, str] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "properties": {"key": "properties", "type": "{str}"}, - } - - def __init__( - self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword service_uri: the service uri to Post the notification when the alert activates or - resolves. - :paramtype service_uri: str - :keyword properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" - self.service_uri = service_uri - self.properties = properties - - -class ServiceDiagnosticSettingsResource(Resource): - """Description of a service diagnostic setting. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you - would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the - format: '{service bus resource ID}/authorizationrules/{key name}'. - :vartype service_bus_rule_id: str - :ivar metrics: the list of metric settings. - :vartype metrics: list[~azure.mgmt.monitor.v2015_07_01.models.MetricSettings] - :ivar logs: the list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2015_07_01.models.LogSettings] - :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. - :vartype workspace_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, - "logs": {"key": "properties.logs", "type": "[LogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - metrics: Optional[List["_models.MetricSettings"]] = None, - logs: Optional[List["_models.LogSettings"]] = None, - workspace_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you - would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the - format: '{service bus resource ID}/authorizationrules/{key name}'. - :paramtype service_bus_rule_id: str - :keyword metrics: the list of metric settings. - :paramtype metrics: list[~azure.mgmt.monitor.v2015_07_01.models.MetricSettings] - :keyword logs: the list of logs settings. - :paramtype logs: list[~azure.mgmt.monitor.v2015_07_01.models.LogSettings] - :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. - :paramtype workspace_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.metrics = metrics - self.logs = logs - self.workspace_id = workspace_id - - -class ServiceSpecification(_serialization.Model): - """One property of operation, include log specifications. - - :ivar log_specifications: Log specifications of operation. - :vartype log_specifications: list[~azure.mgmt.monitor.v2015_07_01.models.LogSpecification] - :ivar metric_specifications: Metric specifications of operation. - :vartype metric_specifications: - list[~azure.mgmt.monitor.v2015_07_01.models.MetricSpecification] - :ivar legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do - not use. - :vartype legacy_metric_specifications: JSON - """ - - _attribute_map = { - "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, - "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, - "legacy_metric_specifications": {"key": "legacyMetricSpecifications", "type": "object"}, - } - - def __init__( - self, - *, - log_specifications: Optional[List["_models.LogSpecification"]] = None, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - legacy_metric_specifications: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_specifications: Log specifications of operation. - :paramtype log_specifications: list[~azure.mgmt.monitor.v2015_07_01.models.LogSpecification] - :keyword metric_specifications: Metric specifications of operation. - :paramtype metric_specifications: - list[~azure.mgmt.monitor.v2015_07_01.models.MetricSpecification] - :keyword legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, - do not use. - :paramtype legacy_metric_specifications: JSON - """ - super().__init__(**kwargs) - self.log_specifications = log_specifications - self.metric_specifications = metric_specifications - self.legacy_metric_specifications = legacy_metric_specifications - - -class TableInfoEntry(_serialization.Model): - """Info about a storage table with metric data. - - :ivar table_name: Name of a table with metric data for this resource. - :vartype table_name: str - :ivar start_time: Start time of the metrics in this table. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the metrics in this table. - :vartype end_time: ~datetime.datetime - :ivar sas_token: For the storage account with metrics. - :vartype sas_token: str - :ivar sas_token_expiration_time: For the storage account with metrics. - :vartype sas_token_expiration_time: ~datetime.datetime - """ - - _attribute_map = { - "table_name": {"key": "tableName", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "sas_token": {"key": "sasToken", "type": "str"}, - "sas_token_expiration_time": {"key": "sasTokenExpirationTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - table_name: Optional[str] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - sas_token: Optional[str] = None, - sas_token_expiration_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword table_name: Name of a table with metric data for this resource. - :paramtype table_name: str - :keyword start_time: Start time of the metrics in this table. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time of the metrics in this table. - :paramtype end_time: ~datetime.datetime - :keyword sas_token: For the storage account with metrics. - :paramtype sas_token: str - :keyword sas_token_expiration_time: For the storage account with metrics. - :paramtype sas_token_expiration_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.table_name = table_name - self.start_time = start_time - self.end_time = end_time - self.sas_token = sas_token - self.sas_token_expiration_time = sas_token_expiration_time - - -class ThresholdRuleCondition(RuleCondition): - """A rule condition based on a metric crossing a threshold. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - :ivar operator: the operator used to compare the data and the threshold. Required. Known values - are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2015_07_01.models.ConditionOperator - :ivar threshold: the threshold value that activates the alert. Required. - :vartype threshold: float - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - :ivar time_aggregation: the time aggregation operator. How the data that are collected should - be combined over time. The default value is the PrimaryAggregationType of the Metric. Known - values are: "Average", "Minimum", "Maximum", "Total", and "Last". - :vartype time_aggregation: str or - ~azure.mgmt.monitor.v2015_07_01.models.TimeAggregationOperator - """ - - _validation = { - "odata_type": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "window_size": {"key": "windowSize", "type": "duration"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - } - - def __init__( - self, - *, - operator: Union[str, "_models.ConditionOperator"], - threshold: float, - data_source: Optional["_models.RuleDataSource"] = None, - window_size: Optional[datetime.timedelta] = None, - time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2015_07_01.models.RuleDataSource - :keyword operator: the operator used to compare the data and the threshold. Required. Known - values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2015_07_01.models.ConditionOperator - :keyword threshold: the threshold value that activates the alert. Required. - :paramtype threshold: float - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - :keyword time_aggregation: the time aggregation operator. How the data that are collected - should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Known values are: "Average", "Minimum", "Maximum", "Total", and "Last". - :paramtype time_aggregation: str or - ~azure.mgmt.monitor.v2015_07_01.models.TimeAggregationOperator - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" - self.operator = operator - self.threshold = threshold - self.window_size = window_size - self.time_aggregation = time_aggregation diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 060b21d2666a9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes how metric values are aggregated.""" - - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - - -class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operators allowed in the rule condition.""" - - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation operators allowed in a rule.""" - - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - LAST = "Last" - - -class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - PERCENT = "Percent" - MILLI_SECONDS = "MilliSeconds" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py deleted file mode 100644 index acff6da37ac2d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._alert_rules_operations import AlertRulesOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ServiceDiagnosticSettingsOperations", - "MetricDefinitionsOperations", - "AlertRulesOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py deleted file mode 100644 index f08dee11cab69..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py +++ /dev/null @@ -1,804 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AlertRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.MonitorManagementClient`'s - :attr:`alert_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.AlertRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - AlertRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AlertRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: - """Gets a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a - AlertRuleResourcePatch type or a IO type. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_rules_resource, (IO, bytes)): - _content = alert_rules_resource - else: - _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_07_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py deleted file mode 100644 index 9e32aa773b3af..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,163 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param filter: Reduces the set of data collected by retrieving particular metric definitions - from all the definitions available for the resource.:code:`
`For example, to get just the - definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% - Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq - :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2015_07_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py deleted file mode 100644 index 37efc4af1b1f3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py +++ /dev/null @@ -1,126 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.MonitorManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.OperationListResult: - """Lists all of the available operations from Microsoft.Insights provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.OperationListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py deleted file mode 100644 index f6e2ac932398f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServiceDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2015_07_01.MonitorManagementClient`'s - :attr:`service_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} - - @overload - def create_or_update( - self, - resource_uri: str, - parameters: _models.ServiceDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a - ServiceDiagnosticSettingsResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2015_07_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py deleted file mode 100644 index 45c019a2dd03b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2016-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json deleted file mode 100644 index 4a901aa6bb4aa..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2016-03-01", - "total_api_version_list": ["2016-03-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "alert_rule_incidents": "AlertRuleIncidentsOperations", - "alert_rules": "AlertRulesOperations", - "log_profiles": "LogProfilesOperations", - "metric_definitions": "MetricDefinitionsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py deleted file mode 100644 index 7102648640c15..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - AlertRuleIncidentsOperations, - AlertRulesOperations, - LogProfilesOperations, - MetricDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations - :vartype alert_rule_incidents: - azure.mgmt.monitor.v2016_03_01.operations.AlertRuleIncidentsOperations - :ivar alert_rules: AlertRulesOperations operations - :vartype alert_rules: azure.mgmt.monitor.v2016_03_01.operations.AlertRulesOperations - :ivar log_profiles: LogProfilesOperations operations - :vartype log_profiles: azure.mgmt.monitor.v2016_03_01.operations.LogProfilesOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2016_03_01.operations.MetricDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alert_rule_incidents = AlertRuleIncidentsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py deleted file mode 100644 index b092b2cb72396..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2016-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py deleted file mode 100644 index dcb044338740f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - AlertRuleIncidentsOperations, - AlertRulesOperations, - LogProfilesOperations, - MetricDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations - :vartype alert_rule_incidents: - azure.mgmt.monitor.v2016_03_01.aio.operations.AlertRuleIncidentsOperations - :ivar alert_rules: AlertRulesOperations operations - :vartype alert_rules: azure.mgmt.monitor.v2016_03_01.aio.operations.AlertRulesOperations - :ivar log_profiles: LogProfilesOperations operations - :vartype log_profiles: azure.mgmt.monitor.v2016_03_01.aio.operations.LogProfilesOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2016_03_01.aio.operations.MetricDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alert_rule_incidents = AlertRuleIncidentsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py deleted file mode 100644 index 185356695cfa8..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._alert_rule_incidents_operations import AlertRuleIncidentsOperations -from ._alert_rules_operations import AlertRulesOperations -from ._log_profiles_operations import LogProfilesOperations -from ._metric_definitions_operations import MetricDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertRuleIncidentsOperations", - "AlertRulesOperations", - "LogProfilesOperations", - "MetricDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py deleted file mode 100644 index 88163d63ffd34..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py +++ /dev/null @@ -1,214 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._alert_rule_incidents_operations import build_get_request, build_list_by_alert_rule_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AlertRuleIncidentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.aio.MonitorManagementClient`'s - :attr:`alert_rule_incidents` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, rule_name: str, incident_name: str, **kwargs: Any - ) -> _models.Incident: - """Gets an incident associated to an alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param incident_name: The name of the incident to retrieve. Required. - :type incident_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Incident or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.Incident - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.Incident] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - incident_name=incident_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Incident", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}" - } - - @distributed_trace - def list_by_alert_rule( - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Incident"]: - """Gets a list of incidents associated to an alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Incident or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2016_03_01.models.Incident] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.IncidentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_alert_rule_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_alert_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("IncidentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_alert_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py deleted file mode 100644 index 7b923b3df73b2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py +++ /dev/null @@ -1,650 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._alert_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AlertRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.aio.MonitorManagementClient`'s - :attr:`alert_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.AlertRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - AlertRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AlertRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: - """Gets a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a - AlertRuleResourcePatch type or a IO type. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_rules_resource, (IO, bytes)): - _content = alert_rules_resource - else: - _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py deleted file mode 100644 index ecabbf2f55912..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py +++ /dev/null @@ -1,498 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._log_profiles_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LogProfilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.aio.MonitorManagementClient`'s - :attr:`log_profiles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, log_profile_name: str, **kwargs: Any - ) -> None: - """Deletes the log profile. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - } - - @distributed_trace_async - async def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: - """Gets the log profile. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) - - request = build_get_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogProfileResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} - - @overload - async def create_or_update( - self, - log_profile_name: str, - parameters: _models.LogProfileResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogProfileResource: - """Create or update a log profile in Azure Monitoring REST API. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, log_profile_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.LogProfileResource: - """Create or update a log profile in Azure Monitoring REST API. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, log_profile_name: str, parameters: Union[_models.LogProfileResource, IO], **kwargs: Any - ) -> _models.LogProfileResource: - """Create or update a log profile in Azure Monitoring REST API. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Is either a LogProfileResource type or - a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LogProfileResource") - - request = build_create_or_update_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogProfileResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - } - - @overload - async def update( - self, - log_profile_name: str, - log_profiles_resource: _models.LogProfileResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogProfileResource: - """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Required. - :type log_profiles_resource: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, log_profile_name: str, log_profiles_resource: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.LogProfileResource: - """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Required. - :type log_profiles_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, log_profile_name: str, log_profiles_resource: Union[_models.LogProfileResourcePatch, IO], **kwargs: Any - ) -> _models.LogProfileResource: - """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Is either a - LogProfileResourcePatch type or a IO type. Required. - :type log_profiles_resource: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResourcePatch or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(log_profiles_resource, (IO, bytes)): - _content = log_profiles_resource - else: - _json = self._serialize.body(log_profiles_resource, "LogProfileResourcePatch") - - request = build_update_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogProfileResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.LogProfileResource"]: - """List the log profiles. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogProfileResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.LogProfileCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LogProfileCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py deleted file mode 100644 index d8a60beccbd5a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,147 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_definitions_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.aio.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param filter: Reduces the set of data collected by retrieving particular metric definitions - from all the definitions available for the resource.:code:`
`For example, to get just the - definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% - Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq - :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2016_03_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py deleted file mode 100644 index 07226e45344b9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AlertRuleResource -from ._models_py3 import AlertRuleResourceCollection -from ._models_py3 import AlertRuleResourcePatch -from ._models_py3 import ErrorResponse -from ._models_py3 import Incident -from ._models_py3 import IncidentListResult -from ._models_py3 import LocalizableString -from ._models_py3 import LocationThresholdRuleCondition -from ._models_py3 import LogProfileCollection -from ._models_py3 import LogProfileResource -from ._models_py3 import LogProfileResourcePatch -from ._models_py3 import ManagementEventAggregationCondition -from ._models_py3 import ManagementEventRuleCondition -from ._models_py3 import MetricAvailability -from ._models_py3 import MetricDefinition -from ._models_py3 import MetricDefinitionCollection -from ._models_py3 import Resource -from ._models_py3 import RetentionPolicy -from ._models_py3 import RuleAction -from ._models_py3 import RuleCondition -from ._models_py3 import RuleDataSource -from ._models_py3 import RuleEmailAction -from ._models_py3 import RuleManagementEventClaimsDataSource -from ._models_py3 import RuleManagementEventDataSource -from ._models_py3 import RuleMetricDataSource -from ._models_py3 import RuleWebhookAction -from ._models_py3 import ThresholdRuleCondition - -from ._monitor_management_client_enums import AggregationType -from ._monitor_management_client_enums import ConditionOperator -from ._monitor_management_client_enums import TimeAggregationOperator -from ._monitor_management_client_enums import Unit -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertRuleResource", - "AlertRuleResourceCollection", - "AlertRuleResourcePatch", - "ErrorResponse", - "Incident", - "IncidentListResult", - "LocalizableString", - "LocationThresholdRuleCondition", - "LogProfileCollection", - "LogProfileResource", - "LogProfileResourcePatch", - "ManagementEventAggregationCondition", - "ManagementEventRuleCondition", - "MetricAvailability", - "MetricDefinition", - "MetricDefinitionCollection", - "Resource", - "RetentionPolicy", - "RuleAction", - "RuleCondition", - "RuleDataSource", - "RuleEmailAction", - "RuleManagementEventClaimsDataSource", - "RuleManagementEventDataSource", - "RuleMetricDataSource", - "RuleWebhookAction", - "ThresholdRuleCondition", - "AggregationType", - "ConditionOperator", - "TimeAggregationOperator", - "Unit", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py deleted file mode 100644 index 9085894db256a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py +++ /dev/null @@ -1,1473 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class AlertRuleResource(Resource): # pylint: disable=too-many-instance-attributes - """The alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar name_properties_name: the name of the alert rule. Required. - :vartype name_properties_name: str - :ivar description: the description of the alert rule that will be included in the alert email. - :vartype description: str - :ivar provisioning_state: the provisioning state. - :vartype provisioning_state: str - :ivar is_enabled: the flag that indicates whether the alert rule is enabled. Required. - :vartype is_enabled: bool - :ivar condition: the condition that results in the alert rule being activated. Required. - :vartype condition: ~azure.mgmt.monitor.v2016_03_01.models.RuleCondition - :ivar action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :vartype action: ~azure.mgmt.monitor.v2016_03_01.models.RuleAction - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2016_03_01.models.RuleAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "name_properties_name": {"required": True}, - "is_enabled": {"required": True}, - "condition": {"required": True}, - "last_updated_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "RuleCondition"}, - "action": {"key": "properties.action", "type": "RuleAction"}, - "actions": {"key": "properties.actions", "type": "[RuleAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - location: str, - name_properties_name: str, - is_enabled: bool, - condition: "_models.RuleCondition", - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - provisioning_state: Optional[str] = None, - action: Optional["_models.RuleAction"] = None, - actions: Optional[List["_models.RuleAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword name_properties_name: the name of the alert rule. Required. - :paramtype name_properties_name: str - :keyword description: the description of the alert rule that will be included in the alert - email. - :paramtype description: str - :keyword provisioning_state: the provisioning state. - :paramtype provisioning_state: str - :keyword is_enabled: the flag that indicates whether the alert rule is enabled. Required. - :paramtype is_enabled: bool - :keyword condition: the condition that results in the alert rule being activated. Required. - :paramtype condition: ~azure.mgmt.monitor.v2016_03_01.models.RuleCondition - :keyword action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :paramtype action: ~azure.mgmt.monitor.v2016_03_01.models.RuleAction - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2016_03_01.models.RuleAction] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.name_properties_name = name_properties_name - self.description = description - self.provisioning_state = provisioning_state - self.is_enabled = is_enabled - self.condition = condition - self.action = action - self.actions = actions - self.last_updated_time = None - - -class AlertRuleResourceCollection(_serialization.Model): - """Represents a collection of alert rule resources. - - :ivar value: the values for the alert rule resources. - :vartype value: list[~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AlertRuleResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: the values for the alert rule resources. - :paramtype value: list[~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource] - """ - super().__init__(**kwargs) - self.value = value - - -class AlertRuleResourcePatch(_serialization.Model): - """The alert rule object for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar name: the name of the alert rule. - :vartype name: str - :ivar description: the description of the alert rule that will be included in the alert email. - :vartype description: str - :ivar provisioning_state: the provisioning state. - :vartype provisioning_state: str - :ivar is_enabled: the flag that indicates whether the alert rule is enabled. - :vartype is_enabled: bool - :ivar condition: the condition that results in the alert rule being activated. - :vartype condition: ~azure.mgmt.monitor.v2016_03_01.models.RuleCondition - :ivar action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :vartype action: ~azure.mgmt.monitor.v2016_03_01.models.RuleAction - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2016_03_01.models.RuleAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - """ - - _validation = { - "last_updated_time": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "name": {"key": "properties.name", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "RuleCondition"}, - "action": {"key": "properties.action", "type": "RuleAction"}, - "actions": {"key": "properties.actions", "type": "[RuleAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - name: Optional[str] = None, - description: Optional[str] = None, - provisioning_state: Optional[str] = None, - is_enabled: Optional[bool] = None, - condition: Optional["_models.RuleCondition"] = None, - action: Optional["_models.RuleAction"] = None, - actions: Optional[List["_models.RuleAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword name: the name of the alert rule. - :paramtype name: str - :keyword description: the description of the alert rule that will be included in the alert - email. - :paramtype description: str - :keyword provisioning_state: the provisioning state. - :paramtype provisioning_state: str - :keyword is_enabled: the flag that indicates whether the alert rule is enabled. - :paramtype is_enabled: bool - :keyword condition: the condition that results in the alert rule being activated. - :paramtype condition: ~azure.mgmt.monitor.v2016_03_01.models.RuleCondition - :keyword action: action that is performed when the alert rule becomes active, and when an alert - condition is resolved. - :paramtype action: ~azure.mgmt.monitor.v2016_03_01.models.RuleAction - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2016_03_01.models.RuleAction] - """ - super().__init__(**kwargs) - self.tags = tags - self.name = name - self.description = description - self.provisioning_state = provisioning_state - self.is_enabled = is_enabled - self.condition = condition - self.action = action - self.actions = actions - self.last_updated_time = None - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class Incident(_serialization.Model): - """An alert incident indicates the activation status of an alert rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Incident name. - :vartype name: str - :ivar rule_name: Rule name that is associated with the incident. - :vartype rule_name: str - :ivar is_active: A boolean to indicate whether the incident is active or resolved. - :vartype is_active: bool - :ivar activated_time: The time at which the incident was activated in ISO8601 format. - :vartype activated_time: ~datetime.datetime - :ivar resolved_time: The time at which the incident was resolved in ISO8601 format. If null, it - means the incident is still active. - :vartype resolved_time: ~datetime.datetime - """ - - _validation = { - "name": {"readonly": True}, - "rule_name": {"readonly": True}, - "is_active": {"readonly": True}, - "activated_time": {"readonly": True}, - "resolved_time": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "rule_name": {"key": "ruleName", "type": "str"}, - "is_active": {"key": "isActive", "type": "bool"}, - "activated_time": {"key": "activatedTime", "type": "iso-8601"}, - "resolved_time": {"key": "resolvedTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.rule_name = None - self.is_active = None - self.activated_time = None - self.resolved_time = None - - -class IncidentListResult(_serialization.Model): - """The List incidents operation response. - - :ivar value: the incident collection. - :vartype value: list[~azure.mgmt.monitor.v2016_03_01.models.Incident] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Incident]"}, - } - - def __init__(self, *, value: Optional[List["_models.Incident"]] = None, **kwargs: Any) -> None: - """ - :keyword value: the incident collection. - :paramtype value: list[~azure.mgmt.monitor.v2016_03_01.models.Incident] - """ - super().__init__(**kwargs) - self.value = value - - -class LocalizableString(_serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the invariant value. Required. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: the invariant value. Required. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class RuleCondition(_serialization.Model): - """The condition that results in the alert rule being activated. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition": "LocationThresholdRuleCondition", - "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition": "ManagementEventRuleCondition", - "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition": "ThresholdRuleCondition", - } - } - - def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs: Any) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - self.data_source = data_source - - -class LocationThresholdRuleCondition(RuleCondition): - """A rule condition based on a certain number of locations failing. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - :ivar failed_location_count: the number of locations that must fail to activate the alert. - Required. - :vartype failed_location_count: int - """ - - _validation = { - "odata_type": {"required": True}, - "failed_location_count": {"required": True, "minimum": 0}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "window_size": {"key": "windowSize", "type": "duration"}, - "failed_location_count": {"key": "failedLocationCount", "type": "int"}, - } - - def __init__( - self, - *, - failed_location_count: int, - data_source: Optional["_models.RuleDataSource"] = None, - window_size: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - :keyword failed_location_count: the number of locations that must fail to activate the alert. - Required. - :paramtype failed_location_count: int - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" - self.window_size = window_size - self.failed_location_count = failed_location_count - - -class LogProfileCollection(_serialization.Model): - """Represents a collection of log profiles. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values of the log profiles. Required. - :vartype value: list[~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[LogProfileResource]"}, - } - - def __init__(self, *, value: List["_models.LogProfileResource"], **kwargs: Any) -> None: - """ - :keyword value: the values of the log profiles. Required. - :paramtype value: list[~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource] - """ - super().__init__(**kwargs) - self.value = value - - -class LogProfileResource(Resource): - """The log profile resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar storage_account_id: the resource id of the storage account to which you would like to - send the Activity Log. - :vartype storage_account_id: str - :ivar service_bus_rule_id: 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}'. - :vartype service_bus_rule_id: str - :ivar locations: 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. Required. - :vartype locations: list[str] - :ivar categories: the categories of the logs. These categories are created as is convenient to - the user. Some values are: 'Write', 'Delete', and/or 'Action.'. Required. - :vartype categories: list[str] - :ivar retention_policy: the retention policy for the events in the log. Required. - :vartype retention_policy: ~azure.mgmt.monitor.v2016_03_01.models.RetentionPolicy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "locations": {"required": True}, - "categories": {"required": True}, - "retention_policy": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "locations": {"key": "properties.locations", "type": "[str]"}, - "categories": {"key": "properties.categories", "type": "[str]"}, - "retention_policy": {"key": "properties.retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - location: str, - locations: List[str], - categories: List[str], - retention_policy: "_models.RetentionPolicy", - tags: Optional[Dict[str, str]] = None, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword storage_account_id: the resource id of the storage account to which you would like to - send the Activity Log. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: 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}'. - :paramtype service_bus_rule_id: str - :keyword locations: 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. Required. - :paramtype locations: list[str] - :keyword categories: the categories of the logs. These categories are created as is convenient - to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. Required. - :paramtype categories: list[str] - :keyword retention_policy: the retention policy for the events in the log. Required. - :paramtype retention_policy: ~azure.mgmt.monitor.v2016_03_01.models.RetentionPolicy - """ - super().__init__(location=location, tags=tags, **kwargs) - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.locations = locations - self.categories = categories - self.retention_policy = retention_policy - - -class LogProfileResourcePatch(_serialization.Model): - """The log profile resource for patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar storage_account_id: the resource id of the storage account to which you would like to - send the Activity Log. - :vartype storage_account_id: str - :ivar service_bus_rule_id: 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}'. - :vartype service_bus_rule_id: str - :ivar locations: 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. - :vartype locations: list[str] - :ivar categories: the categories of the logs. These categories are created as is convenient to - the user. Some values are: 'Write', 'Delete', and/or 'Action.'. - :vartype categories: list[str] - :ivar retention_policy: the retention policy for the events in the log. - :vartype retention_policy: ~azure.mgmt.monitor.v2016_03_01.models.RetentionPolicy - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "locations": {"key": "properties.locations", "type": "[str]"}, - "categories": {"key": "properties.categories", "type": "[str]"}, - "retention_policy": {"key": "properties.retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - locations: Optional[List[str]] = None, - categories: Optional[List[str]] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword storage_account_id: the resource id of the storage account to which you would like to - send the Activity Log. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: 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}'. - :paramtype service_bus_rule_id: str - :keyword locations: 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. - :paramtype locations: list[str] - :keyword categories: the categories of the logs. These categories are created as is convenient - to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. - :paramtype categories: list[str] - :keyword retention_policy: the retention policy for the events in the log. - :paramtype retention_policy: ~azure.mgmt.monitor.v2016_03_01.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.tags = tags - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.locations = locations - self.categories = categories - self.retention_policy = retention_policy - - -class ManagementEventAggregationCondition(_serialization.Model): - """How the data that is collected should be combined over time. - - :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2016_03_01.models.ConditionOperator - :ivar threshold: The threshold value that activates the alert. - :vartype threshold: float - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - """ - - _attribute_map = { - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "window_size": {"key": "windowSize", "type": "duration"}, - } - - def __init__( - self, - *, - operator: Optional[Union[str, "_models.ConditionOperator"]] = None, - threshold: Optional[float] = None, - window_size: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword operator: the condition operator. Known values are: "GreaterThan", - "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2016_03_01.models.ConditionOperator - :keyword threshold: The threshold value that activates the alert. - :paramtype threshold: float - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.operator = operator - self.threshold = threshold - self.window_size = window_size - - -class ManagementEventRuleCondition(RuleCondition): - """A management event rule condition. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - :ivar aggregation: 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. - :vartype aggregation: - ~azure.mgmt.monitor.v2016_03_01.models.ManagementEventAggregationCondition - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "aggregation": {"key": "aggregation", "type": "ManagementEventAggregationCondition"}, - } - - def __init__( - self, - *, - data_source: Optional["_models.RuleDataSource"] = None, - aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - :keyword aggregation: 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. - :paramtype aggregation: - ~azure.mgmt.monitor.v2016_03_01.models.ManagementEventAggregationCondition - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" - self.aggregation = aggregation - - -class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the - retention period for that time grain. - - :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed - as a duration 'PT1M', 'P1D', etc. - :vartype time_grain: ~datetime.timedelta - :ivar retention: the retention period for the metric at the specified timegrain. Expressed as - a duration 'PT1M', 'P1D', etc. - :vartype retention: ~datetime.timedelta - """ - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "retention": {"key": "retention", "type": "duration"}, - } - - def __init__( - self, - *, - time_grain: Optional[datetime.timedelta] = None, - retention: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the time grain specifies the aggregation interval for the metric. - Expressed as a duration 'PT1M', 'P1D', etc. - :paramtype time_grain: ~datetime.timedelta - :keyword retention: the retention period for the metric at the specified timegrain. Expressed - as a duration 'PT1M', 'P1D', etc. - :paramtype retention: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.retention = retention - - -class MetricDefinition(_serialization.Model): - """Metric definition class specifies the metadata for a metric. - - :ivar resource_id: the resource identifier of the resource that emitted the metric. - :vartype resource_id: str - :ivar name: the name and the display name of the metric, i.e. it is a localizable string. - :vartype name: ~azure.mgmt.monitor.v2016_03_01.models.LocalizableString - :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2016_03_01.models.Unit - :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :vartype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2016_03_01.models.AggregationType - :ivar metric_availabilities: the collection of what aggregation intervals are available to be - queried. - :vartype metric_availabilities: list[~azure.mgmt.monitor.v2016_03_01.models.MetricAvailability] - :ivar id: the resource identifier of the metric definition. - :vartype id: str - """ - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "unit": {"key": "unit", "type": "str"}, - "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, - "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, - *, - resource_id: Optional[str] = None, - name: Optional["_models.LocalizableString"] = None, - unit: Optional[Union[str, "_models.Unit"]] = None, - primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, - metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword resource_id: the resource identifier of the resource that emitted the metric. - :paramtype resource_id: str - :keyword name: the name and the display name of the metric, i.e. it is a localizable string. - :paramtype name: ~azure.mgmt.monitor.v2016_03_01.models.LocalizableString - :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2016_03_01.models.Unit - :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :paramtype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2016_03_01.models.AggregationType - :keyword metric_availabilities: the collection of what aggregation intervals are available to - be queried. - :paramtype metric_availabilities: - list[~azure.mgmt.monitor.v2016_03_01.models.MetricAvailability] - :keyword id: the resource identifier of the metric definition. - :paramtype id: str - """ - super().__init__(**kwargs) - self.resource_id = resource_id - self.name = name - self.unit = unit - self.primary_aggregation_type = primary_aggregation_type - self.metric_availabilities = metric_availabilities - self.id = id - - -class MetricDefinitionCollection(_serialization.Model): - """Represents collection of metric definitions. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values for the metric definitions. Required. - :vartype value: list[~azure.mgmt.monitor.v2016_03_01.models.MetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, - } - - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: the values for the metric definitions. Required. - :paramtype value: list[~azure.mgmt.monitor.v2016_03_01.models.MetricDefinition] - """ - super().__init__(**kwargs) - self.value = value - - -class RetentionPolicy(_serialization.Model): - """Specifies the retention policy for the log. - - All required parameters must be populated in order to send to Azure. - - :ivar enabled: a value indicating whether the retention policy is enabled. Required. - :vartype enabled: bool - :ivar days: the number of days for the retention in days. A value of 0 will retain the events - indefinitely. Required. - :vartype days: int - """ - - _validation = { - "enabled": {"required": True}, - "days": {"required": True, "minimum": 0}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "days": {"key": "days", "type": "int"}, - } - - def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: - """ - :keyword enabled: a value indicating whether the retention policy is enabled. Required. - :paramtype enabled: bool - :keyword days: the number of days for the retention in days. A value of 0 will retain the - events indefinitely. Required. - :paramtype days: int - """ - super().__init__(**kwargs) - self.enabled = enabled - self.days = days - - -class RuleAction(_serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is - resolved. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RuleEmailAction, RuleWebhookAction - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.RuleEmailAction": "RuleEmailAction", - "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction": "RuleWebhookAction", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - - -class RuleDataSource(_serialization.Model): - """The resource from which the rule collects its data. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RuleManagementEventDataSource, RuleMetricDataSource - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource": "RuleManagementEventDataSource", - "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource": "RuleMetricDataSource", - } - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - self.resource_uri = resource_uri - self.legacy_resource_id = legacy_resource_id - self.resource_location = resource_location - self.metric_namespace = metric_namespace - - -class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is - always RuleEmailAction in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the - service should be notified when the alert is activated. - :vartype send_to_service_owners: bool - :ivar custom_emails: the list of administrator's custom email addresses to notify of the - activation of the alert. - :vartype custom_emails: list[str] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "send_to_service_owners": {"key": "sendToServiceOwners", "type": "bool"}, - "custom_emails": {"key": "customEmails", "type": "[str]"}, - } - - def __init__( - self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :paramtype send_to_service_owners: bool - :keyword custom_emails: the list of administrator's custom email addresses to notify of the - activation of the alert. - :paramtype custom_emails: list[str] - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" - self.send_to_service_owners = send_to_service_owners - self.custom_emails = custom_emails - - -class RuleManagementEventClaimsDataSource(_serialization.Model): - """The claims for a rule management event data source. - - :ivar email_address: the email address. - :vartype email_address: str - """ - - _attribute_map = { - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, email_address: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword email_address: the email address. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.email_address = email_address - - -class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes - """A rule management event data source. The discriminator fields is always - RuleManagementEventDataSource in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - :ivar event_name: the event name. - :vartype event_name: str - :ivar event_source: the event source. - :vartype event_source: str - :ivar level: the level. - :vartype level: str - :ivar operation_name: The name of the operation that should be checked for. If no name is - provided, any operation will match. - :vartype operation_name: str - :ivar resource_group_name: the resource group name. - :vartype resource_group_name: str - :ivar resource_provider_name: the resource provider name. - :vartype resource_provider_name: str - :ivar status: The status of the operation that should be checked for. If no status is provided, - any status will match. - :vartype status: str - :ivar sub_status: the substatus. - :vartype sub_status: str - :ivar claims: the claims. - :vartype claims: ~azure.mgmt.monitor.v2016_03_01.models.RuleManagementEventClaimsDataSource - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "event_name": {"key": "eventName", "type": "str"}, - "event_source": {"key": "eventSource", "type": "str"}, - "level": {"key": "level", "type": "str"}, - "operation_name": {"key": "operationName", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "resource_provider_name": {"key": "resourceProviderName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "sub_status": {"key": "subStatus", "type": "str"}, - "claims": {"key": "claims", "type": "RuleManagementEventClaimsDataSource"}, - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - event_name: Optional[str] = None, - event_source: Optional[str] = None, - level: Optional[str] = None, - operation_name: Optional[str] = None, - resource_group_name: Optional[str] = None, - resource_provider_name: Optional[str] = None, - status: Optional[str] = None, - sub_status: Optional[str] = None, - claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - :keyword event_name: the event name. - :paramtype event_name: str - :keyword event_source: the event source. - :paramtype event_source: str - :keyword level: the level. - :paramtype level: str - :keyword operation_name: The name of the operation that should be checked for. If no name is - provided, any operation will match. - :paramtype operation_name: str - :keyword resource_group_name: the resource group name. - :paramtype resource_group_name: str - :keyword resource_provider_name: the resource provider name. - :paramtype resource_provider_name: str - :keyword status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :paramtype status: str - :keyword sub_status: the substatus. - :paramtype sub_status: str - :keyword claims: the claims. - :paramtype claims: ~azure.mgmt.monitor.v2016_03_01.models.RuleManagementEventClaimsDataSource - """ - super().__init__( - resource_uri=resource_uri, - legacy_resource_id=legacy_resource_id, - resource_location=resource_location, - metric_namespace=metric_namespace, - **kwargs - ) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" - self.event_name = event_name - self.event_source = event_source - self.level = level - self.operation_name = operation_name - self.resource_group_name = resource_group_name - self.resource_provider_name = resource_provider_name - self.status = status - self.sub_status = sub_status - self.claims = claims - - -class RuleMetricDataSource(RuleDataSource): - """A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of data source. There are two types of rule data sources: - RuleMetricDataSource and RuleManagementEventDataSource. Required. - :vartype odata_type: str - :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this - property cannot be updated for an existing rule. - :vartype resource_uri: str - :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :vartype legacy_resource_id: str - :ivar resource_location: the location of the resource. - :vartype resource_location: str - :ivar metric_namespace: the namespace of the metric. - :vartype metric_namespace: str - :ivar metric_name: the name of the metric that defines what the rule monitors. - :vartype metric_name: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "legacy_resource_id": {"key": "legacyResourceId", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "metric_name": {"key": "metricName", "type": "str"}, - } - - def __init__( - self, - *, - resource_uri: Optional[str] = None, - legacy_resource_id: Optional[str] = None, - resource_location: Optional[str] = None, - metric_namespace: Optional[str] = None, - metric_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :paramtype resource_uri: str - :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. - **NOTE**\ : this property cannot be updated for an existing rule. - :paramtype legacy_resource_id: str - :keyword resource_location: the location of the resource. - :paramtype resource_location: str - :keyword metric_namespace: the namespace of the metric. - :paramtype metric_namespace: str - :keyword metric_name: the name of the metric that defines what the rule monitors. - :paramtype metric_name: str - """ - super().__init__( - resource_uri=resource_uri, - legacy_resource_id=legacy_resource_id, - resource_location=resource_location, - metric_namespace=metric_namespace, - **kwargs - ) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" - self.metric_name = metric_name - - -class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator - is always RuleWebhookAction in this case. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of the action. There are two types of actions: - RuleEmailAction and RuleWebhookAction. Required. - :vartype odata_type: str - :ivar service_uri: the service uri to Post the notification when the alert activates or - resolves. - :vartype service_uri: str - :ivar properties: the dictionary of custom properties to include with the post operation. These - data are appended to the webhook payload. - :vartype properties: dict[str, str] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "properties": {"key": "properties", "type": "{str}"}, - } - - def __init__( - self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword service_uri: the service uri to Post the notification when the alert activates or - resolves. - :paramtype service_uri: str - :keyword properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" - self.service_uri = service_uri - self.properties = properties - - -class ThresholdRuleCondition(RuleCondition): - """A rule condition based on a metric crossing a threshold. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: specifies the type of condition. This can be one of three types: - ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition - (based on the number of failures of a web test), and ThresholdRuleCondition (based on the - threshold of a metric). Required. - :vartype odata_type: str - :ivar data_source: the resource from which the rule collects its data. For this type dataSource - will always be of type RuleMetricDataSource. - :vartype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - :ivar operator: the operator used to compare the data and the threshold. Required. Known values - are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2016_03_01.models.ConditionOperator - :ivar threshold: the threshold value that activates the alert. Required. - :vartype threshold: float - :ivar window_size: 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. - :vartype window_size: ~datetime.timedelta - :ivar time_aggregation: the time aggregation operator. How the data that are collected should - be combined over time. The default value is the PrimaryAggregationType of the Metric. Known - values are: "Average", "Minimum", "Maximum", "Total", and "Last". - :vartype time_aggregation: str or - ~azure.mgmt.monitor.v2016_03_01.models.TimeAggregationOperator - """ - - _validation = { - "odata_type": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "data_source": {"key": "dataSource", "type": "RuleDataSource"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "window_size": {"key": "windowSize", "type": "duration"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - } - - def __init__( - self, - *, - operator: Union[str, "_models.ConditionOperator"], - threshold: float, - data_source: Optional["_models.RuleDataSource"] = None, - window_size: Optional[datetime.timedelta] = None, - time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :paramtype data_source: ~azure.mgmt.monitor.v2016_03_01.models.RuleDataSource - :keyword operator: the operator used to compare the data and the threshold. Required. Known - values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2016_03_01.models.ConditionOperator - :keyword threshold: the threshold value that activates the alert. Required. - :paramtype threshold: float - :keyword window_size: 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. - :paramtype window_size: ~datetime.timedelta - :keyword time_aggregation: the time aggregation operator. How the data that are collected - should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Known values are: "Average", "Minimum", "Maximum", "Total", and "Last". - :paramtype time_aggregation: str or - ~azure.mgmt.monitor.v2016_03_01.models.TimeAggregationOperator - """ - super().__init__(data_source=data_source, **kwargs) - self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" - self.operator = operator - self.threshold = threshold - self.window_size = window_size - self.time_aggregation = time_aggregation diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 39c249cb1d29f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,58 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the primary aggregation type value defining how to use the values for display.""" - - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - - -class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operators allowed in the rule condition.""" - - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation operators allowed in a rule.""" - - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - LAST = "Last" - - -class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - PERCENT = "Percent" - MILLI_SECONDS = "MilliSeconds" - BYTE_SECONDS = "ByteSeconds" - UNSPECIFIED = "Unspecified" - CORES = "Cores" - MILLI_CORES = "MilliCores" - NANO_CORES = "NanoCores" - BITS_PER_SECOND = "BitsPerSecond" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py deleted file mode 100644 index 185356695cfa8..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._alert_rule_incidents_operations import AlertRuleIncidentsOperations -from ._alert_rules_operations import AlertRulesOperations -from ._log_profiles_operations import LogProfilesOperations -from ._metric_definitions_operations import MetricDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertRuleIncidentsOperations", - "AlertRulesOperations", - "LogProfilesOperations", - "MetricDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py deleted file mode 100644 index d088008c787c9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, rule_name: str, incident_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "incidentName": _SERIALIZER.url("incident_name", incident_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_alert_rule_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AlertRuleIncidentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.MonitorManagementClient`'s - :attr:`alert_rule_incidents` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, incident_name: str, **kwargs: Any) -> _models.Incident: - """Gets an incident associated to an alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param incident_name: The name of the incident to retrieve. Required. - :type incident_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Incident or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.Incident - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.Incident] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - incident_name=incident_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Incident", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}" - } - - @distributed_trace - def list_by_alert_rule( - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> Iterable["_models.Incident"]: - """Gets a list of incidents associated to an alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Incident or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2016_03_01.models.Incident] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.IncidentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_alert_rule_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_alert_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("IncidentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_alert_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py deleted file mode 100644 index 7b83bb3f1825a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py +++ /dev/null @@ -1,827 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AlertRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.MonitorManagementClient`'s - :attr:`alert_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.AlertRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_group_name: str, rule_name: str, parameters: Union[_models.AlertRuleResource, IO], **kwargs: Any - ) -> _models.AlertRuleResource: - """Creates or updates a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - AlertRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AlertRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: - """Gets a classic metric alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: _models.AlertRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Required. - :type alert_rules_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - rule_name: str, - alert_rules_resource: Union[_models.AlertRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.AlertRuleResource: - """Updates an existing classic metric AlertRuleResource. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a - AlertRuleResourcePatch type or a IO type. Required. - :type alert_rules_resource: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(alert_rules_resource, (IO, bytes)): - _content = alert_rules_resource - else: - _json = self._serialize.body(alert_rules_resource, "AlertRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AlertRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" - } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: - """List the classic metric alert rules within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2016_03_01.models.AlertRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py deleted file mode 100644 index 2f8ac57fc9e2d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py +++ /dev/null @@ -1,623 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_delete_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_get_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class LogProfilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.MonitorManagementClient`'s - :attr:`log_profiles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def delete(self, log_profile_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Deletes the log profile. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - } - - @distributed_trace - def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: - """Gets the log profile. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) - - request = build_get_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogProfileResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} - - @overload - def create_or_update( - self, - log_profile_name: str, - parameters: _models.LogProfileResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogProfileResource: - """Create or update a log profile in Azure Monitoring REST API. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, log_profile_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.LogProfileResource: - """Create or update a log profile in Azure Monitoring REST API. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, log_profile_name: str, parameters: Union[_models.LogProfileResource, IO], **kwargs: Any - ) -> _models.LogProfileResource: - """Create or update a log profile in Azure Monitoring REST API. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Is either a LogProfileResource type or - a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LogProfileResource") - - request = build_create_or_update_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogProfileResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - } - - @overload - def update( - self, - log_profile_name: str, - log_profiles_resource: _models.LogProfileResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogProfileResource: - """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Required. - :type log_profiles_resource: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, log_profile_name: str, log_profiles_resource: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.LogProfileResource: - """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Required. - :type log_profiles_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, log_profile_name: str, log_profiles_resource: Union[_models.LogProfileResourcePatch, IO], **kwargs: Any - ) -> _models.LogProfileResource: - """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. - - :param log_profile_name: The name of the log profile. Required. - :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Is either a - LogProfileResourcePatch type or a IO type. Required. - :type log_profiles_resource: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResourcePatch or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogProfileResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(log_profiles_resource, (IO, bytes)): - _content = log_profiles_resource - else: - _json = self._serialize.body(log_profiles_resource, "LogProfileResourcePatch") - - request = build_update_request( - log_profile_name=log_profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogProfileResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.LogProfileResource"]: - """List the log profiles. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogProfileResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2016_03_01.models.LogProfileResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.LogProfileCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("LogProfileCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py deleted file mode 100644 index 03b71f5a91061..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,175 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricDefinitions") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_03_01.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param filter: Reduces the set of data collected by retrieving particular metric definitions - from all the definitions available for the resource.:code:`
`For example, to get just the - definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% - Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq - :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2016_03_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py deleted file mode 100644 index 562b6f4def407..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2016-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json deleted file mode 100644 index 43644548c2d7a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "chosen_version": "2016-09-01", - "total_api_version_list": ["2016-09-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "metrics": "MetricsOperations", - "service_diagnostic_settings": "ServiceDiagnosticSettingsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py deleted file mode 100644 index d892cfe155157..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py +++ /dev/null @@ -1,87 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2016_09_01.operations.MetricsOperations - :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: - azure.mgmt.monitor.v2016_09_01.operations.ServiceDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py deleted file mode 100644 index fe87248263156..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2016-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py deleted file mode 100644 index 7b1d43f0764ea..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,87 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2016_09_01.aio.operations.MetricsOperations - :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: - azure.mgmt.monitor.v2016_09_01.aio.operations.ServiceDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py deleted file mode 100644 index ba50816b0687c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metrics_operations import MetricsOperations -from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricsOperations", - "ServiceDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py deleted file mode 100644 index bdce1709ba5b4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py +++ /dev/null @@ -1,156 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metrics_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_09_01.aio.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.Metric"]: - """Lists the metric values for a resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param filter: Reduces the set of data collected.:code:`
`The filter is optional. If present - it must contain a list of metric names to retrieve of the form: *(name.value eq 'metricName' - [or name.value eq 'metricName' or ...])*. Optionally, the filter can contain conditions for the - following attributes *aggregationType*\ , *startTime*\ , *endTime*\ , and *timeGrain* of the - form *attributeName operator value*. Where operator is one of *ne*\ , *eq*\ , *gt*\ , - *lt*.:code:`
`Several conditions can be combined with parentheses and logical operators, - e.g: *and*\ , *or*.:code:`
`Some example filter expressions are::code:`
`- - $filter=(name.value eq 'RunsSucceeded') and aggregationType eq 'Total' and startTime eq - 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq duration'PT1M',:code:`
`- - $filter=(name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or aggregationType eq - 'Average') and startTime eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - duration'PT1H',:code:`
`- $filter=(name.value eq 'ActionsCompleted' or name.value eq - 'RunsSucceeded') and (aggregationType eq 'Total' or aggregationType eq 'Average') and startTime - eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - duration'PT1M'.:code:`
`:code:`
`\ **NOTE**\ : When a metrics query comes in with - multiple metrics, but with no aggregation types defined, the service will pick the Primary - aggregation type of the first metrics to be used as the default aggregation type for all the - metrics. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2016_09_01.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - cls: ClsType[_models.MetricCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py deleted file mode 100644 index 73cfe0f9daacb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py +++ /dev/null @@ -1,366 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._service_diagnostic_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ServiceDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_09_01.aio.MonitorManagementClient`'s - :attr:`service_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. **WARNING**\ : This method will - be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} - - @overload - async def create_or_update( - self, - resource_uri: str, - parameters: _models.ServiceDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method - will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method - will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method - will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a - ServiceDiagnosticSettingsResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} - - @overload - async def update( - self, - resource_uri: str, - service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the - CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. - :type service_diagnostic_settings_resource: - ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_uri: str, - service_diagnostic_settings_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the - CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. - :type service_diagnostic_settings_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_uri: str, - service_diagnostic_settings_resource: Union[_models.ServiceDiagnosticSettingsResourcePatch, IO], - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the - CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a - ServiceDiagnosticSettingsResourcePatch type or a IO type. Required. - :type service_diagnostic_settings_resource: - ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(service_diagnostic_settings_resource, (IO, bytes)): - _content = service_diagnostic_settings_resource - else: - _json = self._serialize.body(service_diagnostic_settings_resource, "ServiceDiagnosticSettingsResourcePatch") - - request = build_update_request( - resource_uri=resource_uri, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py deleted file mode 100644 index 6404a337a3f8b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorResponse -from ._models_py3 import LocalizableString -from ._models_py3 import LogSettings -from ._models_py3 import Metric -from ._models_py3 import MetricCollection -from ._models_py3 import MetricSettings -from ._models_py3 import MetricValue -from ._models_py3 import Resource -from ._models_py3 import RetentionPolicy -from ._models_py3 import ServiceDiagnosticSettingsResource -from ._models_py3 import ServiceDiagnosticSettingsResourcePatch - -from ._monitor_management_client_enums import Unit -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorResponse", - "LocalizableString", - "LogSettings", - "Metric", - "MetricCollection", - "MetricSettings", - "MetricValue", - "Resource", - "RetentionPolicy", - "ServiceDiagnosticSettingsResource", - "ServiceDiagnosticSettingsResourcePatch", - "Unit", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py deleted file mode 100644 index 21c5db38e5b15..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py +++ /dev/null @@ -1,598 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class LocalizableString(_serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the invariant value. Required. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: the invariant value. Required. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class LogSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: 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. - :vartype category: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this log. - :vartype retention_policy: ~azure.mgmt.monitor.v2016_09_01.models.RetentionPolicy - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - enabled: bool, - category: Optional[str] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword category: 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. - :paramtype category: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this log. - :paramtype retention_policy: ~azure.mgmt.monitor.v2016_09_01.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.category = category - self.enabled = enabled - self.retention_policy = retention_policy - - -class Metric(_serialization.Model): - """A set of metric values in a time range. - - All required parameters must be populated in order to send to Azure. - - :ivar id: the id, resourceId, of the metric. - :vartype id: str - :ivar type: the resource type of the metric resource. - :vartype type: str - :ivar name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :vartype name: ~azure.mgmt.monitor.v2016_09_01.models.LocalizableString - :ivar unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2016_09_01.models.Unit - :ivar data: Array of data points representing the metric values. Required. - :vartype data: list[~azure.mgmt.monitor.v2016_09_01.models.MetricValue] - """ - - _validation = { - "name": {"required": True}, - "unit": {"required": True}, - "data": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "unit": {"key": "unit", "type": "str"}, - "data": {"key": "data", "type": "[MetricValue]"}, - } - - def __init__( - self, - *, - name: "_models.LocalizableString", - unit: Union[str, "_models.Unit"], - data: List["_models.MetricValue"], - id: Optional[str] = None, # pylint: disable=redefined-builtin - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: the id, resourceId, of the metric. - :paramtype id: str - :keyword type: the resource type of the metric resource. - :paramtype type: str - :keyword name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :paramtype name: ~azure.mgmt.monitor.v2016_09_01.models.LocalizableString - :keyword unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2016_09_01.models.Unit - :keyword data: Array of data points representing the metric values. Required. - :paramtype data: list[~azure.mgmt.monitor.v2016_09_01.models.MetricValue] - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.name = name - self.unit = unit - self.data = data - - -class MetricCollection(_serialization.Model): - """The collection of metric value sets. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the value of the collection. Required. - :vartype value: list[~azure.mgmt.monitor.v2016_09_01.models.Metric] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Metric]"}, - } - - def __init__(self, *, value: List["_models.Metric"], **kwargs: Any) -> None: - """ - :keyword value: the value of the collection. Required. - :paramtype value: list[~azure.mgmt.monitor.v2016_09_01.models.Metric] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - All required parameters must be populated in order to send to Azure. - - :ivar time_grain: the timegrain of the metric in ISO8601 format. Required. - :vartype time_grain: ~datetime.timedelta - :ivar enabled: a value indicating whether this timegrain is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this timegrain. - :vartype retention_policy: ~azure.mgmt.monitor.v2016_09_01.models.RetentionPolicy - """ - - _validation = { - "time_grain": {"required": True}, - "enabled": {"required": True}, - } - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - time_grain: datetime.timedelta, - enabled: bool, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the timegrain of the metric in ISO8601 format. Required. - :paramtype time_grain: ~datetime.timedelta - :keyword enabled: a value indicating whether this timegrain is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this timegrain. - :paramtype retention_policy: ~azure.mgmt.monitor.v2016_09_01.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.enabled = enabled - self.retention_policy = retention_policy - - -class MetricValue(_serialization.Model): - """Represents a metric value. - - All required parameters must be populated in order to send to Azure. - - :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :vartype time_stamp: ~datetime.datetime - :ivar average: the average value in the time range. - :vartype average: float - :ivar minimum: the least value in the time range. - :vartype minimum: float - :ivar maximum: the greatest value in the time range. - :vartype maximum: float - :ivar total: the sum of all of the values in the time range. - :vartype total: float - :ivar count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :vartype count: int - """ - - _validation = { - "time_stamp": {"required": True}, - } - - _attribute_map = { - "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, - "average": {"key": "average", "type": "float"}, - "minimum": {"key": "minimum", "type": "float"}, - "maximum": {"key": "maximum", "type": "float"}, - "total": {"key": "total", "type": "float"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__( - self, - *, - time_stamp: datetime.datetime, - average: Optional[float] = None, - minimum: Optional[float] = None, - maximum: Optional[float] = None, - total: Optional[float] = None, - count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :paramtype time_stamp: ~datetime.datetime - :keyword average: the average value in the time range. - :paramtype average: float - :keyword minimum: the least value in the time range. - :paramtype minimum: float - :keyword maximum: the greatest value in the time range. - :paramtype maximum: float - :keyword total: the sum of all of the values in the time range. - :paramtype total: float - :keyword count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :paramtype count: int - """ - super().__init__(**kwargs) - self.time_stamp = time_stamp - self.average = average - self.minimum = minimum - self.maximum = maximum - self.total = total - self.count = count - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class RetentionPolicy(_serialization.Model): - """Specifies the retention policy for the log. - - All required parameters must be populated in order to send to Azure. - - :ivar enabled: a value indicating whether the retention policy is enabled. Required. - :vartype enabled: bool - :ivar days: the number of days for the retention in days. A value of 0 will retain the events - indefinitely. Required. - :vartype days: int - """ - - _validation = { - "enabled": {"required": True}, - "days": {"required": True, "minimum": 0}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "days": {"key": "days", "type": "int"}, - } - - def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: - """ - :keyword enabled: a value indicating whether the retention policy is enabled. Required. - :paramtype enabled: bool - :keyword days: the number of days for the retention in days. A value of 0 will retain the - events indefinitely. Required. - :paramtype days: int - """ - super().__init__(**kwargs) - self.enabled = enabled - self.days = days - - -class ServiceDiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes - """Description of a service diagnostic setting. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you - would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the - format: '{service bus resource ID}/authorizationrules/{key name}'. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace - authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar metrics: the list of metric settings. - :vartype metrics: list[~azure.mgmt.monitor.v2016_09_01.models.MetricSettings] - :ivar logs: the list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2016_09_01.models.LogSettings] - :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. - :vartype workspace_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, - "logs": {"key": "properties.logs", "type": "[LogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - metrics: Optional[List["_models.MetricSettings"]] = None, - logs: Optional[List["_models.LogSettings"]] = None, - workspace_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you - would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the - format: '{service bus resource ID}/authorizationrules/{key name}'. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace - authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword metrics: the list of metric settings. - :paramtype metrics: list[~azure.mgmt.monitor.v2016_09_01.models.MetricSettings] - :keyword logs: the list of logs settings. - :paramtype logs: list[~azure.mgmt.monitor.v2016_09_01.models.LogSettings] - :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. - :paramtype workspace_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.metrics = metrics - self.logs = logs - self.workspace_id = workspace_id - - -class ServiceDiagnosticSettingsResourcePatch(_serialization.Model): - """Service diagnostic setting resource for patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you - would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the - format: '{service bus resource ID}/authorizationrules/{key name}'. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace - authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar metrics: the list of metric settings. - :vartype metrics: list[~azure.mgmt.monitor.v2016_09_01.models.MetricSettings] - :ivar logs: the list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2016_09_01.models.LogSettings] - :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. - :vartype workspace_id: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, - "logs": {"key": "properties.logs", "type": "[LogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - metrics: Optional[List["_models.MetricSettings"]] = None, - logs: Optional[List["_models.LogSettings"]] = None, - workspace_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you - would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the - format: '{service bus resource ID}/authorizationrules/{key name}'. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace - authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword metrics: the list of metric settings. - :paramtype metrics: list[~azure.mgmt.monitor.v2016_09_01.models.MetricSettings] - :keyword logs: the list of logs settings. - :paramtype logs: list[~azure.mgmt.monitor.v2016_09_01.models.LogSettings] - :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a 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. - :paramtype workspace_id: str - """ - super().__init__(**kwargs) - self.tags = tags - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.metrics = metrics - self.logs = logs - self.workspace_id = workspace_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py deleted file mode 100644 index e8d8442d73e06..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - PERCENT = "Percent" - MILLI_SECONDS = "MilliSeconds" - BYTE_SECONDS = "ByteSeconds" - UNSPECIFIED = "Unspecified" - CORES = "Cores" - MILLI_CORES = "MilliCores" - NANO_CORES = "NanoCores" - BITS_PER_SECOND = "BitsPerSecond" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py deleted file mode 100644 index ba50816b0687c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metrics_operations import MetricsOperations -from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricsOperations", - "ServiceDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py deleted file mode 100644 index dbc2237106945..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py +++ /dev/null @@ -1,185 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metrics") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_09_01.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.Metric"]: - """Lists the metric values for a resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param filter: Reduces the set of data collected.:code:`
`The filter is optional. If present - it must contain a list of metric names to retrieve of the form: *(name.value eq 'metricName' - [or name.value eq 'metricName' or ...])*. Optionally, the filter can contain conditions for the - following attributes *aggregationType*\ , *startTime*\ , *endTime*\ , and *timeGrain* of the - form *attributeName operator value*. Where operator is one of *ne*\ , *eq*\ , *gt*\ , - *lt*.:code:`
`Several conditions can be combined with parentheses and logical operators, - e.g: *and*\ , *or*.:code:`
`Some example filter expressions are::code:`
`- - $filter=(name.value eq 'RunsSucceeded') and aggregationType eq 'Total' and startTime eq - 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq duration'PT1M',:code:`
`- - $filter=(name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or aggregationType eq - 'Average') and startTime eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - duration'PT1H',:code:`
`- $filter=(name.value eq 'ActionsCompleted' or name.value eq - 'RunsSucceeded') and (aggregationType eq 'Total' or aggregationType eq 'Average') and startTime - eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq - duration'PT1M'.:code:`
`:code:`
`\ **NOTE**\ : When a metrics query comes in with - multiple metrics, but with no aggregation types defined, the service will pick the Primary - aggregation type of the first metrics to be used as the default aggregation type for all the - metrics. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2016_09_01.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - cls: ClsType[_models.MetricCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py deleted file mode 100644 index 4f09c027be1cf..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py +++ /dev/null @@ -1,443 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServiceDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2016_09_01.MonitorManagementClient`'s - :attr:`service_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. **WARNING**\ : This method will - be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} - - @overload - def create_or_update( - self, - resource_uri: str, - parameters: _models.ServiceDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method - will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, resource_uri: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method - will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_uri: str, parameters: Union[_models.ServiceDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method - will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a - ServiceDiagnosticSettingsResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServiceDiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} - - @overload - def update( - self, - resource_uri: str, - service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the - CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. - :type service_diagnostic_settings_resource: - ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_uri: str, - service_diagnostic_settings_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the - CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. Required. - :type service_diagnostic_settings_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_uri: str, - service_diagnostic_settings_resource: Union[_models.ServiceDiagnosticSettingsResourcePatch, IO], - **kwargs: Any - ) -> _models.ServiceDiagnosticSettingsResource: - """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the - CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a - ServiceDiagnosticSettingsResourcePatch type or a IO type. Required. - :type service_diagnostic_settings_resource: - ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2016_09_01.models.ServiceDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(service_diagnostic_settings_resource, (IO, bytes)): - _content = service_diagnostic_settings_resource - else: - _json = self._serialize.body(service_diagnostic_settings_resource, "ServiceDiagnosticSettingsResourcePatch") - - request = build_update_request( - resource_uri=resource_uri, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServiceDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py deleted file mode 100644 index fdcd1f8c74566..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json deleted file mode 100644 index 9efc7cb572fef..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2017-03-01-preview", - "total_api_version_list": ["2017-03-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "activity_log_alerts": "ActivityLogAlertsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py deleted file mode 100644 index 8e181236d253f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogAlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: - azure.mgmt.monitor.v2017_03_01_preview.operations.ActivityLogAlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py deleted file mode 100644 index 40ec0a582da1a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 47608ace8a5cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogAlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: - azure.mgmt.monitor.v2017_03_01_preview.aio.operations.ActivityLogAlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py deleted file mode 100644 index b024a2af0682a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._activity_log_alerts_operations import ActivityLogAlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivityLogAlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py deleted file mode 100644 index 61c912abf42b6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py +++ /dev/null @@ -1,660 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._activity_log_alerts_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActivityLogAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_03_01_preview.aio.MonitorManagementClient`'s - :attr:`activity_log_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: _models.ActivityLogAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: Union[_models.ActivityLogAlertResource, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Is either a - ActivityLogAlertResource type or a IO type. Required. - :type activity_log_alert: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert, (IO, bytes)): - _content = activity_log_alert - else: - _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Get an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> None: - """Delete an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @overload - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: _models.ActivityLogAlertResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: Union[_models.ActivityLogAlertResourcePatch, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a - ActivityLogAlertResourcePatch type or a IO type. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_patch, (IO, bytes)): - _content = activity_log_alert_patch - else: - _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py deleted file mode 100644 index 0ca76e5f619d5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActivityLogAlertActionGroup -from ._models_py3 import ActivityLogAlertActionList -from ._models_py3 import ActivityLogAlertAllOfCondition -from ._models_py3 import ActivityLogAlertLeafCondition -from ._models_py3 import ActivityLogAlertList -from ._models_py3 import ActivityLogAlertResource -from ._models_py3 import ActivityLogAlertResourcePatch -from ._models_py3 import ErrorResponse -from ._models_py3 import Resource -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivityLogAlertActionGroup", - "ActivityLogAlertActionList", - "ActivityLogAlertAllOfCondition", - "ActivityLogAlertLeafCondition", - "ActivityLogAlertList", - "ActivityLogAlertResource", - "ActivityLogAlertResourcePatch", - "ErrorResponse", - "Resource", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py deleted file mode 100644 index b0c4fb509c4a8..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py +++ /dev/null @@ -1,389 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActivityLogAlertActionGroup(_serialization.Model): - """A pointer to an Azure Action Group. - - All required parameters must be populated in order to send to Azure. - - :ivar action_group_id: The resourceId of the action group. This cannot be null or empty. - Required. - :vartype action_group_id: str - :ivar webhook_properties: The dictionary of custom properties to include with the post - operation. These data are appended to the webhook payload. - :vartype webhook_properties: dict[str, str] - """ - - _validation = { - "action_group_id": {"required": True}, - } - - _attribute_map = { - "action_group_id": {"key": "actionGroupId", "type": "str"}, - "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, - } - - def __init__( - self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword action_group_id: The resourceId of the action group. This cannot be null or empty. - Required. - :paramtype action_group_id: str - :keyword webhook_properties: The dictionary of custom properties to include with the post - operation. These data are appended to the webhook payload. - :paramtype webhook_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.action_group_id = action_group_id - self.webhook_properties = webhook_properties - - -class ActivityLogAlertActionList(_serialization.Model): - """A list of activity log alert actions. - - :ivar action_groups: The list of activity log alerts. - :vartype action_groups: - list[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertActionGroup] - """ - - _attribute_map = { - "action_groups": {"key": "actionGroups", "type": "[ActivityLogAlertActionGroup]"}, - } - - def __init__( - self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs: Any - ) -> None: - """ - :keyword action_groups: The list of activity log alerts. - :paramtype action_groups: - list[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertActionGroup] - """ - super().__init__(**kwargs) - self.action_groups = action_groups - - -class ActivityLogAlertAllOfCondition(_serialization.Model): - """An Activity Log alert condition that is met when all its member conditions are met. - - All required parameters must be populated in order to send to Azure. - - :ivar all_of: The list of activity log alert conditions. Required. - :vartype all_of: - list[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertLeafCondition] - """ - - _validation = { - "all_of": {"required": True}, - } - - _attribute_map = { - "all_of": {"key": "allOf", "type": "[ActivityLogAlertLeafCondition]"}, - } - - def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs: Any) -> None: - """ - :keyword all_of: The list of activity log alert conditions. Required. - :paramtype all_of: - list[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertLeafCondition] - """ - super().__init__(**kwargs) - self.all_of = all_of - - -class ActivityLogAlertLeafCondition(_serialization.Model): - """An Activity Log alert condition that is met by comparing an activity log field and value. - - All required parameters must be populated in order to send to Azure. - - :ivar field: The name of the field that this condition will examine. The possible values for - this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', - 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. Required. - :vartype field: str - :ivar equals: The field value will be compared to this value (case-insensitive) to determine if - the condition is met. Required. - :vartype equals: str - """ - - _validation = { - "field": {"required": True}, - "equals": {"required": True}, - } - - _attribute_map = { - "field": {"key": "field", "type": "str"}, - "equals": {"key": "equals", "type": "str"}, - } - - def __init__(self, *, field: str, equals: str, **kwargs: Any) -> None: - """ - :keyword field: The name of the field that this condition will examine. The possible values for - this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', - 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. Required. - :paramtype field: str - :keyword equals: The field value will be compared to this value (case-insensitive) to determine - if the condition is met. Required. - :paramtype equals: str - """ - super().__init__(**kwargs) - self.field = field - self.equals = equals - - -class ActivityLogAlertList(_serialization.Model): - """A list of activity log alerts. - - :ivar value: The list of activity log alerts. - :vartype value: list[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.ActivityLogAlertResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of activity log alerts. - :paramtype value: list[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource] - """ - super().__init__(**kwargs) - self.value = value - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActivityLogAlertResource(Resource): - """An activity log alert resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to - activityLogs with resourceIds that fall under one of these prefixes. This list must include at - least one item. - :vartype scopes: list[str] - :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert - is not enabled, then none of its actions will be activated. - :vartype enabled: bool - :ivar condition: The condition that will cause this alert to activate. - :vartype condition: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertAllOfCondition - :ivar actions: The actions that will activate when the condition is met. - :vartype actions: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertActionList - :ivar description: A description of this activity log alert. - :vartype description: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "ActivityLogAlertAllOfCondition"}, - "actions": {"key": "properties.actions", "type": "ActivityLogAlertActionList"}, - "description": {"key": "properties.description", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - scopes: Optional[List[str]] = None, - enabled: bool = True, - condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, - actions: Optional["_models.ActivityLogAlertActionList"] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply - to activityLogs with resourceIds that fall under one of these prefixes. This list must include - at least one item. - :paramtype scopes: list[str] - :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log - alert is not enabled, then none of its actions will be activated. - :paramtype enabled: bool - :keyword condition: The condition that will cause this alert to activate. - :paramtype condition: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertAllOfCondition - :keyword actions: The actions that will activate when the condition is met. - :paramtype actions: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertActionList - :keyword description: A description of this activity log alert. - :paramtype description: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.scopes = scopes - self.enabled = enabled - self.condition = condition - self.actions = actions - self.description = description - - -class ActivityLogAlertResourcePatch(Resource): - """An activity log alert resource for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert - is not enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__( - self, *, location: str, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log - alert is not enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.enabled = enabled - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py deleted file mode 100644 index b024a2af0682a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._activity_log_alerts_operations import ActivityLogAlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivityLogAlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py deleted file mode 100644 index 850077311db85..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py +++ /dev/null @@ -1,847 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActivityLogAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_03_01_preview.MonitorManagementClient`'s - :attr:`activity_log_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: _models.ActivityLogAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: Union[_models.ActivityLogAlertResource, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Is either a - ActivityLogAlertResource type or a IO type. Required. - :type activity_log_alert: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert, (IO, bytes)): - _content = activity_log_alert - else: - _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def get( - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Get an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> None: - """Delete an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @overload - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: _models.ActivityLogAlertResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: Union[_models.ActivityLogAlertResourcePatch, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a - ActivityLogAlertResourcePatch type or a IO type. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_patch, (IO, bytes)): - _content = activity_log_alert_patch - else: - _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_03_01_preview.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py deleted file mode 100644 index 9cbb2f0deda34..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json deleted file mode 100644 index 6eaf6b0143794..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2017-04-01", - "total_api_version_list": ["2017-04-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations", - "activity_log_alerts": "ActivityLogAlertsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py deleted file mode 100644 index 6ce7c69392ab4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, ActivityLogAlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2017_04_01.operations.ActionGroupsOperations - :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: - azure.mgmt.monitor.v2017_04_01.operations.ActivityLogAlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py deleted file mode 100644 index 8a6aabc450e2b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py deleted file mode 100644 index e0679b80cee63..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, ActivityLogAlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2017_04_01.aio.operations.ActionGroupsOperations - :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: - azure.mgmt.monitor.v2017_04_01.aio.operations.ActivityLogAlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py deleted file mode 100644 index 204d3d1aa9c78..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._activity_log_alerts_operations import ActivityLogAlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "ActivityLogAlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index b7e49ee0bde7d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,792 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_04_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2017_04_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2017_04_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py deleted file mode 100644 index 6817f7dda6297..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py +++ /dev/null @@ -1,658 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._activity_log_alerts_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActivityLogAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_04_01.aio.MonitorManagementClient`'s - :attr:`activity_log_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: _models.ActivityLogAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: Union[_models.ActivityLogAlertResource, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Is either a - ActivityLogAlertResource type or a IO type. Required. - :type activity_log_alert: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert, (IO, bytes)): - _content = activity_log_alert - else: - _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Get an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> None: - """Delete an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @overload - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: _models.ActivityLogAlertPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: Union[_models.ActivityLogAlertPatchBody, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a - ActivityLogAlertPatchBody type or a IO type. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_patch, (IO, bytes)): - _content = activity_log_alert_patch - else: - _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py deleted file mode 100644 index 353a71918f692..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py +++ /dev/null @@ -1,57 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ActivityLogAlertActionGroup -from ._models_py3 import ActivityLogAlertActionList -from ._models_py3 import ActivityLogAlertAllOfCondition -from ._models_py3 import ActivityLogAlertLeafCondition -from ._models_py3 import ActivityLogAlertList -from ._models_py3 import ActivityLogAlertPatchBody -from ._models_py3 import ActivityLogAlertResource -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import ItsmReceiver -from ._models_py3 import Resource -from ._models_py3 import SmsReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ActivityLogAlertActionGroup", - "ActivityLogAlertActionList", - "ActivityLogAlertAllOfCondition", - "ActivityLogAlertLeafCondition", - "ActivityLogAlertList", - "ActivityLogAlertPatchBody", - "ActivityLogAlertResource", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "ItsmReceiver", - "Resource", - "SmsReceiver", - "WebhookReceiver", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py deleted file mode 100644 index 8a9f989dad6b0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py +++ /dev/null @@ -1,878 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(Resource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2017_04_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2017_04_01.models.AutomationRunbookReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2017_04_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2017_04_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2017_04_01.models.AutomationRunbookReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - - -class ActivityLogAlertActionGroup(_serialization.Model): - """A pointer to an Azure Action Group. - - All required parameters must be populated in order to send to Azure. - - :ivar action_group_id: The resourceId of the action group. This cannot be null or empty. - Required. - :vartype action_group_id: str - :ivar webhook_properties: the dictionary of custom properties to include with the post - operation. These data are appended to the webhook payload. - :vartype webhook_properties: dict[str, str] - """ - - _validation = { - "action_group_id": {"required": True}, - } - - _attribute_map = { - "action_group_id": {"key": "actionGroupId", "type": "str"}, - "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, - } - - def __init__( - self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword action_group_id: The resourceId of the action group. This cannot be null or empty. - Required. - :paramtype action_group_id: str - :keyword webhook_properties: the dictionary of custom properties to include with the post - operation. These data are appended to the webhook payload. - :paramtype webhook_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.action_group_id = action_group_id - self.webhook_properties = webhook_properties - - -class ActivityLogAlertActionList(_serialization.Model): - """A list of activity log alert actions. - - :ivar action_groups: The list of activity log alerts. - :vartype action_groups: - list[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertActionGroup] - """ - - _attribute_map = { - "action_groups": {"key": "actionGroups", "type": "[ActivityLogAlertActionGroup]"}, - } - - def __init__( - self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs: Any - ) -> None: - """ - :keyword action_groups: The list of activity log alerts. - :paramtype action_groups: - list[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertActionGroup] - """ - super().__init__(**kwargs) - self.action_groups = action_groups - - -class ActivityLogAlertAllOfCondition(_serialization.Model): - """An Activity Log alert condition that is met when all its member conditions are met. - - All required parameters must be populated in order to send to Azure. - - :ivar all_of: The list of activity log alert conditions. Required. - :vartype all_of: list[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertLeafCondition] - """ - - _validation = { - "all_of": {"required": True}, - } - - _attribute_map = { - "all_of": {"key": "allOf", "type": "[ActivityLogAlertLeafCondition]"}, - } - - def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs: Any) -> None: - """ - :keyword all_of: The list of activity log alert conditions. Required. - :paramtype all_of: list[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertLeafCondition] - """ - super().__init__(**kwargs) - self.all_of = all_of - - -class ActivityLogAlertLeafCondition(_serialization.Model): - """An Activity Log alert condition that is met by comparing an activity log field and value. - - All required parameters must be populated in order to send to Azure. - - :ivar field: The name of the field that this condition will examine. The possible values for - this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', - 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. Required. - :vartype field: str - :ivar equals: The field value will be compared to this value (case-insensitive) to determine if - the condition is met. Required. - :vartype equals: str - """ - - _validation = { - "field": {"required": True}, - "equals": {"required": True}, - } - - _attribute_map = { - "field": {"key": "field", "type": "str"}, - "equals": {"key": "equals", "type": "str"}, - } - - def __init__(self, *, field: str, equals: str, **kwargs: Any) -> None: - """ - :keyword field: The name of the field that this condition will examine. The possible values for - this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', - 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or - anything beginning with 'properties.'. Required. - :paramtype field: str - :keyword equals: The field value will be compared to this value (case-insensitive) to determine - if the condition is met. Required. - :paramtype equals: str - """ - super().__init__(**kwargs) - self.field = field - self.equals = equals - - -class ActivityLogAlertList(_serialization.Model): - """A list of activity log alerts. - - :ivar value: The list of activity log alerts. - :vartype value: list[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActivityLogAlertResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of activity log alerts. - :paramtype value: list[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActivityLogAlertPatchBody(_serialization.Model): - """An activity log alert object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert - is not enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log - alert is not enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class ActivityLogAlertResource(Resource): - """An activity log alert resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to - activityLogs with resourceIds that fall under one of these prefixes. This list must include at - least one item. - :vartype scopes: list[str] - :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert - is not enabled, then none of its actions will be activated. - :vartype enabled: bool - :ivar condition: The condition that will cause this alert to activate. - :vartype condition: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertAllOfCondition - :ivar actions: The actions that will activate when the condition is met. - :vartype actions: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertActionList - :ivar description: A description of this activity log alert. - :vartype description: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "ActivityLogAlertAllOfCondition"}, - "actions": {"key": "properties.actions", "type": "ActivityLogAlertActionList"}, - "description": {"key": "properties.description", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - scopes: Optional[List[str]] = None, - enabled: bool = True, - condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, - actions: Optional["_models.ActivityLogAlertActionList"] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply - to activityLogs with resourceIds that fall under one of these prefixes. This list must include - at least one item. - :paramtype scopes: list[str] - :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log - alert is not enabled, then none of its actions will be activated. - :paramtype enabled: bool - :keyword condition: The condition that will cause this alert to activate. - :paramtype condition: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertAllOfCondition - :keyword actions: The actions that will activate when the condition is met. - :paramtype actions: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertActionList - :keyword description: A description of this activity log alert. - :paramtype description: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.scopes = scopes - self.enabled = enabled - self.condition = condition - self.actions = actions - self.description = description - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2017_04_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2017_04_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - } - - def __init__(self, *, name: str, service_uri: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 2502d854d1869..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py deleted file mode 100644 index 204d3d1aa9c78..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._activity_log_alerts_operations import ActivityLogAlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "ActivityLogAlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py deleted file mode 100644 index ec9b3d745d80f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,1014 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_04_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2017_04_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2017_04_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py deleted file mode 100644 index 5ec2a2b958b40..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py +++ /dev/null @@ -1,845 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActivityLogAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_04_01.MonitorManagementClient`'s - :attr:`activity_log_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: _models.ActivityLogAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Required. - :type activity_log_alert: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert: Union[_models.ActivityLogAlertResource, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new activity log alert or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert: The activity log alert to create or use for the update. Is either a - ActivityLogAlertResource type or a IO type. Required. - :type activity_log_alert: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert, (IO, bytes)): - _content = activity_log_alert - else: - _json = self._serialize.body(activity_log_alert, "ActivityLogAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def get( - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Get an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> None: - """Delete an activity log alert. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @overload - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: _models.ActivityLogAlertPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_patch: Union[_models.ActivityLogAlertPatchBody, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates an existing ActivityLogAlertResource's tags. To update other fields use the - CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the activity log alert. Required. - :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a - ActivityLogAlertPatchBody type or a IO type. Required. - :type activity_log_alert_patch: - ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_patch, (IO, bytes)): - _content = activity_log_alert_patch - else: - _json = self._serialize.body(activity_log_alert_patch, "ActivityLogAlertPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActivityLogAlertResource"]: - """Get a list of all activity log alerts in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_04_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) - cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py deleted file mode 100644 index 4997675f65341..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json deleted file mode 100644 index 98a13f9d03620..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2017-05-01-preview", - "total_api_version_list": ["2017-05-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "diagnostic_settings_category": "DiagnosticSettingsCategoryOperations", - "diagnostic_settings": "DiagnosticSettingsOperations", - "metric_definitions": "MetricDefinitionsOperations", - "metrics": "MetricsOperations", - "subscription_diagnostic_settings": "SubscriptionDiagnosticSettingsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py deleted file mode 100644 index 716984e952e15..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - DiagnosticSettingsCategoryOperations, - DiagnosticSettingsOperations, - MetricDefinitionsOperations, - MetricsOperations, - SubscriptionDiagnosticSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: - azure.mgmt.monitor.v2017_05_01_preview.operations.DiagnosticSettingsCategoryOperations - :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: - azure.mgmt.monitor.v2017_05_01_preview.operations.DiagnosticSettingsOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2017_05_01_preview.operations.MetricDefinitionsOperations - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2017_05_01_preview.operations.MetricsOperations - :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: - azure.mgmt.monitor.v2017_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py deleted file mode 100644 index 850cb89324d22..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 086db347d6d99..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - DiagnosticSettingsCategoryOperations, - DiagnosticSettingsOperations, - MetricDefinitionsOperations, - MetricsOperations, - SubscriptionDiagnosticSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: - azure.mgmt.monitor.v2017_05_01_preview.aio.operations.DiagnosticSettingsCategoryOperations - :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: - azure.mgmt.monitor.v2017_05_01_preview.aio.operations.DiagnosticSettingsOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2017_05_01_preview.aio.operations.MetricDefinitionsOperations - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2017_05_01_preview.aio.operations.MetricsOperations - :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: - azure.mgmt.monitor.v2017_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index ce13a3cecdd5f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._diagnostic_settings_category_operations import DiagnosticSettingsCategoryOperations -from ._diagnostic_settings_operations import DiagnosticSettingsOperations -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._metrics_operations import MetricsOperations -from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DiagnosticSettingsCategoryOperations", - "DiagnosticSettingsOperations", - "MetricDefinitionsOperations", - "MetricsOperations", - "SubscriptionDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py deleted file mode 100644 index 0d83e355a73aa..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ /dev/null @@ -1,167 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DiagnosticSettingsCategoryOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.aio.MonitorManagementClient`'s - :attr:`diagnostic_settings_category` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: - """Gets the diagnostic settings category for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} - - @distributed_trace_async - async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: - """Lists the diagnostic settings categories for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResourceCollection or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py deleted file mode 100644 index dc66df3a6c663..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ /dev/null @@ -1,356 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._diagnostic_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.aio.MonitorManagementClient`'s - :attr:`diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @overload - async def create_or_update( - self, - resource_uri: str, - name: str, - parameters: _models.DiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace_async - async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsResourceCollection: - """Gets the active diagnostic settings list for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResourceCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py deleted file mode 100644 index 4fc92805e16b4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_definitions_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.aio.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py deleted file mode 100644 index 9f58ae2b706a4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metrics_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.aio.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, - resource_uri: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metric: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any - ) -> _models.Response: - """**Lists the metric values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metric: The name of the metric to retrieve. Default value is None. - :type metric: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.Response - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.Response] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - timespan=timespan, - interval=interval, - metric=metric, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Response", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py deleted file mode 100644 index 943d33f893aa0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ /dev/null @@ -1,345 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._subscription_diagnostic_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SubscriptionDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.aio.MonitorManagementClient`'s - :attr:`subscription_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: - """Gets the active subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} - - @overload - async def create_or_update( - self, - name: str, - parameters: _models.SubscriptionDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - SubscriptionDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") - - request = build_create_or_update_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @distributed_trace_async - async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Deletes existing subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: - """Gets the active subscription diagnostic settings list for the specified subscriptionId. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py deleted file mode 100644 index b0c0eda562787..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import DiagnosticSettingsCategoryResource -from ._models_py3 import DiagnosticSettingsCategoryResourceCollection -from ._models_py3 import DiagnosticSettingsResource -from ._models_py3 import DiagnosticSettingsResourceCollection -from ._models_py3 import ErrorResponse -from ._models_py3 import LocalizableString -from ._models_py3 import LogSettings -from ._models_py3 import MetadataValue -from ._models_py3 import Metric -from ._models_py3 import MetricAvailability -from ._models_py3 import MetricDefinition -from ._models_py3 import MetricDefinitionCollection -from ._models_py3 import MetricSettings -from ._models_py3 import MetricValue -from ._models_py3 import ProxyOnlyResource -from ._models_py3 import Response -from ._models_py3 import RetentionPolicy -from ._models_py3 import SubscriptionDiagnosticSettingsResource -from ._models_py3 import SubscriptionDiagnosticSettingsResourceCollection -from ._models_py3 import SubscriptionLogSettings -from ._models_py3 import SubscriptionProxyOnlyResource -from ._models_py3 import TimeSeriesElement - -from ._monitor_management_client_enums import AggregationType -from ._monitor_management_client_enums import CategoryType -from ._monitor_management_client_enums import ResultType -from ._monitor_management_client_enums import Unit -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DiagnosticSettingsCategoryResource", - "DiagnosticSettingsCategoryResourceCollection", - "DiagnosticSettingsResource", - "DiagnosticSettingsResourceCollection", - "ErrorResponse", - "LocalizableString", - "LogSettings", - "MetadataValue", - "Metric", - "MetricAvailability", - "MetricDefinition", - "MetricDefinitionCollection", - "MetricSettings", - "MetricValue", - "ProxyOnlyResource", - "Response", - "RetentionPolicy", - "SubscriptionDiagnosticSettingsResource", - "SubscriptionDiagnosticSettingsResourceCollection", - "SubscriptionLogSettings", - "SubscriptionProxyOnlyResource", - "TimeSeriesElement", - "AggregationType", - "CategoryType", - "ResultType", - "Unit", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py deleted file mode 100644 index 0564434e908a0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1079 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ProxyOnlyResource(_serialization.Model): - """A proxy only azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DiagnosticSettingsCategoryResource(ProxyOnlyResource): - """The diagnostic settings category resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics" - and "Logs". - :vartype category_type: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.CategoryType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "category_type": {"key": "properties.categoryType", "type": "str"}, - } - - def __init__(self, *, category_type: Optional[Union[str, "_models.CategoryType"]] = None, **kwargs: Any) -> None: - """ - :keyword category_type: The type of the diagnostic settings category. Known values are: - "Metrics" and "Logs". - :paramtype category_type: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.CategoryType - """ - super().__init__(**kwargs) - self.category_type = category_type - - -class DiagnosticSettingsCategoryResourceCollection(_serialization.Model): - """Represents a collection of diagnostic setting category resources. - - :ivar value: The collection of diagnostic settings category resources. - :vartype value: - list[~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DiagnosticSettingsCategoryResource]"}, - } - - def __init__( - self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection of diagnostic settings category resources. - :paramtype value: - list[~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] - """ - super().__init__(**kwargs) - self.value = value - - -class DiagnosticSettingsResource(ProxyOnlyResource): # pylint: disable=too-many-instance-attributes - """The diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to - maintain backwards compatibility. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :vartype event_hub_name: str - :ivar metrics: The list of metric settings. - :vartype metrics: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricSettings] - :ivar logs: The list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2017_05_01_preview.models.LogSettings] - :ivar workspace_id: 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. - :vartype workspace_id: str - :ivar log_analytics_destination_type: 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: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :vartype log_analytics_destination_type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, - "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, - "logs": {"key": "properties.logs", "type": "[LogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - "log_analytics_destination_type": {"key": "properties.logAnalyticsDestinationType", "type": "str"}, - } - - def __init__( - self, - *, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - event_hub_name: Optional[str] = None, - metrics: Optional[List["_models.MetricSettings"]] = None, - logs: Optional[List["_models.LogSettings"]] = None, - workspace_id: Optional[str] = None, - log_analytics_destination_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here - to maintain backwards compatibility. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :paramtype event_hub_name: str - :keyword metrics: The list of metric settings. - :paramtype metrics: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricSettings] - :keyword logs: The list of logs settings. - :paramtype logs: list[~azure.mgmt.monitor.v2017_05_01_preview.models.LogSettings] - :keyword workspace_id: 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. - :paramtype workspace_id: str - :keyword log_analytics_destination_type: 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: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :paramtype log_analytics_destination_type: str - """ - super().__init__(**kwargs) - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.event_hub_name = event_hub_name - self.metrics = metrics - self.logs = logs - self.workspace_id = workspace_id - self.log_analytics_destination_type = log_analytics_destination_type - - -class DiagnosticSettingsResourceCollection(_serialization.Model): - """Represents a collection of alert rule resources. - - :ivar value: The collection of diagnostic settings resources;. - :vartype value: list[~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DiagnosticSettingsResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The collection of diagnostic settings resources;. - :paramtype value: - list[~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource] - """ - super().__init__(**kwargs) - self.value = value - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class LocalizableString(_serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the invariant value. Required. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: the invariant value. Required. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class LogSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: 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. - :vartype category: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this log. - :vartype retention_policy: ~azure.mgmt.monitor.v2017_05_01_preview.models.RetentionPolicy - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - enabled: bool, - category: Optional[str] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword category: 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. - :paramtype category: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this log. - :paramtype retention_policy: ~azure.mgmt.monitor.v2017_05_01_preview.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.category = category - self.enabled = enabled - self.retention_policy = retention_policy - - -class MetadataValue(_serialization.Model): - """Represents a metric metadata value. - - :ivar name: the name of the metadata. - :vartype name: ~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString - :ivar value: the value of the metadata. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "LocalizableString"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__( - self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: the name of the metadata. - :paramtype name: ~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString - :keyword value: the value of the metadata. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class Metric(_serialization.Model): - """The result data of a query. - - All required parameters must be populated in order to send to Azure. - - :ivar id: the metric Id. Required. - :vartype id: str - :ivar type: the resource type of the metric resource. Required. - :vartype type: str - :ivar name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :vartype name: ~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar error_code: 'Success' or the error details on query failures for this metric. - :vartype error_code: str - :ivar error_message: Error message encountered querying this specific metric. - :vartype error_message: str - :ivar unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.Unit - :ivar timeseries: the time series returned when a data query is performed. Required. - :vartype timeseries: list[~azure.mgmt.monitor.v2017_05_01_preview.models.TimeSeriesElement] - """ - - _validation = { - "id": {"required": True}, - "type": {"required": True}, - "name": {"required": True}, - "unit": {"required": True}, - "timeseries": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "timeseries": {"key": "timeseries", "type": "[TimeSeriesElement]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - type: str, - name: "_models.LocalizableString", - unit: Union[str, "_models.Unit"], - timeseries: List["_models.TimeSeriesElement"], - display_description: Optional[str] = None, - error_code: Optional[str] = None, - error_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: the metric Id. Required. - :paramtype id: str - :keyword type: the resource type of the metric resource. Required. - :paramtype type: str - :keyword name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :paramtype name: ~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword error_code: 'Success' or the error details on query failures for this metric. - :paramtype error_code: str - :keyword error_message: Error message encountered querying this specific metric. - :paramtype error_message: str - :keyword unit: the unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.Unit - :keyword timeseries: the time series returned when a data query is performed. Required. - :paramtype timeseries: list[~azure.mgmt.monitor.v2017_05_01_preview.models.TimeSeriesElement] - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.name = name - self.display_description = display_description - self.error_code = error_code - self.error_message = error_message - self.unit = unit - self.timeseries = timeseries - - -class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the - retention period for that time grain. - - :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed - as a duration 'PT1M', 'P1D', etc. - :vartype time_grain: ~datetime.timedelta - :ivar retention: the retention period for the metric at the specified timegrain. Expressed as - a duration 'PT1M', 'P1D', etc. - :vartype retention: ~datetime.timedelta - """ - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "retention": {"key": "retention", "type": "duration"}, - } - - def __init__( - self, - *, - time_grain: Optional[datetime.timedelta] = None, - retention: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the time grain specifies the aggregation interval for the metric. - Expressed as a duration 'PT1M', 'P1D', etc. - :paramtype time_grain: ~datetime.timedelta - :keyword retention: the retention period for the metric at the specified timegrain. Expressed - as a duration 'PT1M', 'P1D', etc. - :paramtype retention: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.retention = retention - - -class MetricDefinition(_serialization.Model): - """Metric definition class specifies the metadata for a metric. - - :ivar is_dimension_required: Flag to indicate whether the dimension is required. - :vartype is_dimension_required: bool - :ivar resource_id: the resource identifier of the resource that emitted the metric. - :vartype resource_id: str - :ivar name: the name and the display name of the metric, i.e. it is a localizable string. - :vartype name: ~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar category: Custom category name for this metric. - :vartype category: str - :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.Unit - :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :vartype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2017_05_01_preview.models.AggregationType - :ivar metric_availabilities: the collection of what aggregation intervals are available to be - queried. - :vartype metric_availabilities: - list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricAvailability] - :ivar id: the resource identifier of the metric definition. - :vartype id: str - :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :vartype dimensions: list[~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString] - """ - - _attribute_map = { - "is_dimension_required": {"key": "isDimensionRequired", "type": "bool"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, - "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, - "id": {"key": "id", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[LocalizableString]"}, - } - - def __init__( - self, - *, - is_dimension_required: Optional[bool] = None, - resource_id: Optional[str] = None, - name: Optional["_models.LocalizableString"] = None, - display_description: Optional[str] = None, - category: Optional[str] = None, - unit: Optional[Union[str, "_models.Unit"]] = None, - primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, - metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - dimensions: Optional[List["_models.LocalizableString"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_dimension_required: Flag to indicate whether the dimension is required. - :paramtype is_dimension_required: bool - :keyword resource_id: the resource identifier of the resource that emitted the metric. - :paramtype resource_id: str - :keyword name: the name and the display name of the metric, i.e. it is a localizable string. - :paramtype name: ~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword category: Custom category name for this metric. - :paramtype category: str - :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.Unit - :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :paramtype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2017_05_01_preview.models.AggregationType - :keyword metric_availabilities: the collection of what aggregation intervals are available to - be queried. - :paramtype metric_availabilities: - list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricAvailability] - :keyword id: the resource identifier of the metric definition. - :paramtype id: str - :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :paramtype dimensions: list[~azure.mgmt.monitor.v2017_05_01_preview.models.LocalizableString] - """ - super().__init__(**kwargs) - self.is_dimension_required = is_dimension_required - self.resource_id = resource_id - self.name = name - self.display_description = display_description - self.category = category - self.unit = unit - self.primary_aggregation_type = primary_aggregation_type - self.metric_availabilities = metric_availabilities - self.id = id - self.dimensions = dimensions - - -class MetricDefinitionCollection(_serialization.Model): - """Represents collection of metric definitions. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values for the metric definitions. Required. - :vartype value: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, - } - - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: the values for the metric definitions. Required. - :paramtype value: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricDefinition] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - All required parameters must be populated in order to send to Azure. - - :ivar time_grain: the timegrain of the metric in ISO8601 format. - :vartype time_grain: ~datetime.timedelta - :ivar category: 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. - :vartype category: str - :ivar enabled: a value indicating whether this category is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this category. - :vartype retention_policy: ~azure.mgmt.monitor.v2017_05_01_preview.models.RetentionPolicy - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "category": {"key": "category", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - enabled: bool, - time_grain: Optional[datetime.timedelta] = None, - category: Optional[str] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the timegrain of the metric in ISO8601 format. - :paramtype time_grain: ~datetime.timedelta - :keyword category: 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. - :paramtype category: str - :keyword enabled: a value indicating whether this category is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this category. - :paramtype retention_policy: ~azure.mgmt.monitor.v2017_05_01_preview.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.category = category - self.enabled = enabled - self.retention_policy = retention_policy - - -class MetricValue(_serialization.Model): - """Represents a metric value. - - All required parameters must be populated in order to send to Azure. - - :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :vartype time_stamp: ~datetime.datetime - :ivar average: the average value in the time range. - :vartype average: float - :ivar minimum: the least value in the time range. - :vartype minimum: float - :ivar maximum: the greatest value in the time range. - :vartype maximum: float - :ivar total: the sum of all of the values in the time range. - :vartype total: float - :ivar count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :vartype count: int - """ - - _validation = { - "time_stamp": {"required": True}, - } - - _attribute_map = { - "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, - "average": {"key": "average", "type": "float"}, - "minimum": {"key": "minimum", "type": "float"}, - "maximum": {"key": "maximum", "type": "float"}, - "total": {"key": "total", "type": "float"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__( - self, - *, - time_stamp: datetime.datetime, - average: Optional[float] = None, - minimum: Optional[float] = None, - maximum: Optional[float] = None, - total: Optional[float] = None, - count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :paramtype time_stamp: ~datetime.datetime - :keyword average: the average value in the time range. - :paramtype average: float - :keyword minimum: the least value in the time range. - :paramtype minimum: float - :keyword maximum: the greatest value in the time range. - :paramtype maximum: float - :keyword total: the sum of all of the values in the time range. - :paramtype total: float - :keyword count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :paramtype count: int - """ - super().__init__(**kwargs) - self.time_stamp = time_stamp - self.average = average - self.minimum = minimum - self.maximum = maximum - self.total = total - self.count = count - - -class Response(_serialization.Model): - """The response to a metrics query. - - All required parameters must be populated in order to send to Azure. - - :ivar cost: The integer value representing the relative cost of the query. - :vartype cost: int - :ivar timespan: 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. Required. - :vartype timespan: str - :ivar interval: 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. - :vartype interval: ~datetime.timedelta - :ivar value: the value of the collection. Required. - :vartype value: list[~azure.mgmt.monitor.v2017_05_01_preview.models.Metric] - """ - - _validation = { - "cost": {"minimum": 0}, - "timespan": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "cost": {"key": "cost", "type": "int"}, - "timespan": {"key": "timespan", "type": "str"}, - "interval": {"key": "interval", "type": "duration"}, - "value": {"key": "value", "type": "[Metric]"}, - } - - def __init__( - self, - *, - timespan: str, - value: List["_models.Metric"], - cost: Optional[int] = None, - interval: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword cost: The integer value representing the relative cost of the query. - :paramtype cost: int - :keyword timespan: 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. Required. - :paramtype timespan: str - :keyword interval: 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. - :paramtype interval: ~datetime.timedelta - :keyword value: the value of the collection. Required. - :paramtype value: list[~azure.mgmt.monitor.v2017_05_01_preview.models.Metric] - """ - super().__init__(**kwargs) - self.cost = cost - self.timespan = timespan - self.interval = interval - self.value = value - - -class RetentionPolicy(_serialization.Model): - """Specifies the retention policy for the log. - - All required parameters must be populated in order to send to Azure. - - :ivar enabled: a value indicating whether the retention policy is enabled. Required. - :vartype enabled: bool - :ivar days: the number of days for the retention in days. A value of 0 will retain the events - indefinitely. Required. - :vartype days: int - """ - - _validation = { - "enabled": {"required": True}, - "days": {"required": True, "minimum": 0}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "days": {"key": "days", "type": "int"}, - } - - def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: - """ - :keyword enabled: a value indicating whether the retention policy is enabled. Required. - :paramtype enabled: bool - :keyword days: the number of days for the retention in days. A value of 0 will retain the - events indefinitely. Required. - :paramtype days: int - """ - super().__init__(**kwargs) - self.enabled = enabled - self.days = days - - -class SubscriptionProxyOnlyResource(_serialization.Model): - """A proxy only azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Location of the resource. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location of the resource. - :paramtype location: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - - -class SubscriptionDiagnosticSettingsResource(SubscriptionProxyOnlyResource): - """The subscription diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Location of the resource. - :vartype location: str - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to - maintain backwards compatibility. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :vartype event_hub_name: str - :ivar logs: The list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionLogSettings] - :ivar workspace_id: 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. - :vartype workspace_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, - "logs": {"key": "properties.logs", "type": "[SubscriptionLogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - event_hub_name: Optional[str] = None, - logs: Optional[List["_models.SubscriptionLogSettings"]] = None, - workspace_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Location of the resource. - :paramtype location: str - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here - to maintain backwards compatibility. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :paramtype event_hub_name: str - :keyword logs: The list of logs settings. - :paramtype logs: list[~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionLogSettings] - :keyword workspace_id: 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. - :paramtype workspace_id: str - """ - super().__init__(location=location, **kwargs) - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.event_hub_name = event_hub_name - self.logs = logs - self.workspace_id = workspace_id - - -class SubscriptionDiagnosticSettingsResourceCollection(_serialization.Model): - """Represents a collection of subscription diagnostic settings resources. - - :ivar value: The collection of subscription diagnostic settings resources. - :vartype value: - list[~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[SubscriptionDiagnosticSettingsResource]"}, - } - - def __init__( - self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection of subscription diagnostic settings resources. - :paramtype value: - list[~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - """ - super().__init__(**kwargs) - self.value = value - - -class SubscriptionLogSettings(_serialization.Model): - """Part of Subscription diagnostic setting. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting - is applied to. - :vartype category: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: bool, category: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword category: Name of a Subscription Diagnostic Log category for a resource type this - setting is applied to. - :paramtype category: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.category = category - self.enabled = enabled - - -class TimeSeriesElement(_serialization.Model): - """A time series result type. The discriminator value is always TimeSeries in this case. - - :ivar metadatavalues: the metadata values returned if $filter was specified in the call. - :vartype metadatavalues: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetadataValue] - :ivar data: An array of data points representing the metric values. This is only returned if a - result type of data is specified. - :vartype data: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricValue] - """ - - _attribute_map = { - "metadatavalues": {"key": "metadatavalues", "type": "[MetadataValue]"}, - "data": {"key": "data", "type": "[MetricValue]"}, - } - - def __init__( - self, - *, - metadatavalues: Optional[List["_models.MetadataValue"]] = None, - data: Optional[List["_models.MetricValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword metadatavalues: the metadata values returned if $filter was specified in the call. - :paramtype metadatavalues: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetadataValue] - :keyword data: An array of data points representing the metric values. This is only returned - if a result type of data is specified. - :paramtype data: list[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricValue] - """ - super().__init__(**kwargs) - self.metadatavalues = metadatavalues - self.data = data diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index eeb4aaf62f459..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the primary aggregation type value defining how to use the values for display.""" - - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - - -class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the diagnostic settings category.""" - - METRICS = "Metrics" - LOGS = "Logs" - - -class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ResultType.""" - - DATA = "Data" - METADATA = "Metadata" - - -class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - PERCENT = "Percent" - MILLI_SECONDS = "MilliSeconds" - BYTE_SECONDS = "ByteSeconds" - UNSPECIFIED = "Unspecified" - CORES = "Cores" - MILLI_CORES = "MilliCores" - NANO_CORES = "NanoCores" - BITS_PER_SECOND = "BitsPerSecond" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py deleted file mode 100644 index ce13a3cecdd5f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._diagnostic_settings_category_operations import DiagnosticSettingsCategoryOperations -from ._diagnostic_settings_operations import DiagnosticSettingsOperations -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._metrics_operations import MetricsOperations -from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DiagnosticSettingsCategoryOperations", - "DiagnosticSettingsOperations", - "MetricDefinitionsOperations", - "MetricsOperations", - "SubscriptionDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py deleted file mode 100644 index 8ce4544b481d7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ /dev/null @@ -1,219 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DiagnosticSettingsCategoryOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.MonitorManagementClient`'s - :attr:`diagnostic_settings_category` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: - """Gets the diagnostic settings category for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: - """Lists the diagnostic settings categories for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResourceCollection or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py deleted file mode 100644 index 8b00888644775..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py +++ /dev/null @@ -1,456 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.MonitorManagementClient`'s - :attr:`diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @overload - def create_or_update( - self, - resource_uri: str, - name: str, - parameters: _models.DiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsResourceCollection: - """Gets the active diagnostic settings list for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.DiagnosticSettingsResourceCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py deleted file mode 100644 index 335a3a180e77e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,164 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricDefinitions") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_05_01_preview.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py deleted file mode 100644 index de3f7287bb161..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py +++ /dev/null @@ -1,215 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_uri: str, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metric: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metrics") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if timespan is not None: - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - if metric is not None: - _params["metric"] = _SERIALIZER.query("metric", metric, "str") - if aggregation is not None: - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if result_type is not None: - _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, - resource_uri: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metric: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any - ) -> _models.Response: - """**Lists the metric values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metric: The name of the metric to retrieve. Default value is None. - :type metric: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2017_05_01_preview.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.Response - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.Response] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - timespan=timespan, - interval=interval, - metric=metric, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Response", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py deleted file mode 100644 index c63a9c5463a6b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ /dev/null @@ -1,451 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class SubscriptionDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_05_01_preview.MonitorManagementClient`'s - :attr:`subscription_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: - """Gets the active subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} - - @overload - def create_or_update( - self, - name: str, - parameters: _models.SubscriptionDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - SubscriptionDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") - - request = build_create_or_update_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @distributed_trace - def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Deletes existing subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} - - @distributed_trace - def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: - """Gets the active subscription diagnostic settings list for the specified subscriptionId. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py deleted file mode 100644 index 005178cd14075..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-12-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json deleted file mode 100644 index 19de87bd9d48b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2017-12-01-preview", - "total_api_version_list": ["2017-12-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "metric_namespaces": "MetricNamespacesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py deleted file mode 100644 index 5bd19e332aaa1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,84 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricNamespacesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metric_namespaces: MetricNamespacesOperations operations - :vartype metric_namespaces: - azure.mgmt.monitor.v2017_12_01_preview.operations.MetricNamespacesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metric_namespaces = MetricNamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py deleted file mode 100644 index e54d5ce7c1efa..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2017-12-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 498ac41557788..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,84 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricNamespacesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metric_namespaces: MetricNamespacesOperations operations - :vartype metric_namespaces: - azure.mgmt.monitor.v2017_12_01_preview.aio.operations.MetricNamespacesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metric_namespaces = MetricNamespacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py deleted file mode 100644 index b230e557d8236..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metric_namespaces_operations import MetricNamespacesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricNamespacesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py deleted file mode 100644 index 93f2ea7416a03..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_namespaces_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricNamespacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_12_01_preview.aio.MonitorManagementClient`'s - :attr:`metric_namespaces` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, start_time: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricNamespace"]: - """Lists the metric namespaces for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param start_time: The ISO 8601 conform Date start time from which to query for metric - namespaces. Default value is None. - :type start_time: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricNamespace or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2017_12_01_preview.models.MetricNamespace] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) - cls: ClsType[_models.MetricNamespaceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - start_time=start_time, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py deleted file mode 100644 index f4b8efc1b5b03..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorResponse -from ._models_py3 import MetricNamespace -from ._models_py3 import MetricNamespaceCollection -from ._models_py3 import MetricNamespaceName - -from ._monitor_management_client_enums import NamespaceClassification -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorResponse", - "MetricNamespace", - "MetricNamespaceCollection", - "MetricNamespaceName", - "NamespaceClassification", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py deleted file mode 100644 index 693997b7abe7d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class MetricNamespace(_serialization.Model): - """Metric namespace class specifies the metadata for a metric namespace. - - :ivar id: The ID of the metric namespace. - :vartype id: str - :ivar type: The type of the namespace. - :vartype type: str - :ivar name: The escaped name of the namespace. - :vartype name: str - :ivar classification: Kind of namespace. Known values are: "Platform", "Custom", and "Qos". - :vartype classification: str or - ~azure.mgmt.monitor.v2017_12_01_preview.models.NamespaceClassification - :ivar properties: Properties which include the fully qualified namespace name. - :vartype properties: ~azure.mgmt.monitor.v2017_12_01_preview.models.MetricNamespaceName - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "classification": {"key": "classification", "type": "str"}, - "properties": {"key": "properties", "type": "MetricNamespaceName"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - type: Optional[str] = None, - name: Optional[str] = None, - classification: Optional[Union[str, "_models.NamespaceClassification"]] = None, - properties: Optional["_models.MetricNamespaceName"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The ID of the metric namespace. - :paramtype id: str - :keyword type: The type of the namespace. - :paramtype type: str - :keyword name: The escaped name of the namespace. - :paramtype name: str - :keyword classification: Kind of namespace. Known values are: "Platform", "Custom", and "Qos". - :paramtype classification: str or - ~azure.mgmt.monitor.v2017_12_01_preview.models.NamespaceClassification - :keyword properties: Properties which include the fully qualified namespace name. - :paramtype properties: ~azure.mgmt.monitor.v2017_12_01_preview.models.MetricNamespaceName - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.name = name - self.classification = classification - self.properties = properties - - -class MetricNamespaceCollection(_serialization.Model): - """Represents collection of metric namespaces. - - All required parameters must be populated in order to send to Azure. - - :ivar value: The values for the metric namespaces. Required. - :vartype value: list[~azure.mgmt.monitor.v2017_12_01_preview.models.MetricNamespace] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[MetricNamespace]"}, - } - - def __init__(self, *, value: List["_models.MetricNamespace"], **kwargs: Any) -> None: - """ - :keyword value: The values for the metric namespaces. Required. - :paramtype value: list[~azure.mgmt.monitor.v2017_12_01_preview.models.MetricNamespace] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricNamespaceName(_serialization.Model): - """The fully qualified metric namespace name. - - :ivar metric_namespace_name: The metric namespace name. - :vartype metric_namespace_name: str - """ - - _attribute_map = { - "metric_namespace_name": {"key": "metricNamespaceName", "type": "str"}, - } - - def __init__(self, *, metric_namespace_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword metric_namespace_name: The metric namespace name. - :paramtype metric_namespace_name: str - """ - super().__init__(**kwargs) - self.metric_namespace_name = metric_namespace_name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 8800607a4dac2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class NamespaceClassification(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Kind of namespace.""" - - PLATFORM = "Platform" - CUSTOM = "Custom" - QOS = "Qos" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py deleted file mode 100644 index b230e557d8236..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metric_namespaces_operations import MetricNamespacesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricNamespacesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py deleted file mode 100644 index 77c5e20d065de..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py +++ /dev/null @@ -1,172 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_uri: str, *, start_time: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricNamespaces") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if start_time is not None: - _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricNamespacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2017_12_01_preview.MonitorManagementClient`'s - :attr:`metric_namespaces` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, start_time: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricNamespace"]: - """Lists the metric namespaces for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param start_time: The ISO 8601 conform Date start time from which to query for metric - namespaces. Default value is None. - :type start_time: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricNamespace or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2017_12_01_preview.models.MetricNamespace] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) - cls: ClsType[_models.MetricNamespaceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - start_time=start_time, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py deleted file mode 100644 index dad9cbbe64f27..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json deleted file mode 100644 index 1079b3dba2901..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "chosen_version": "2018-01-01", - "total_api_version_list": ["2018-01-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "metric_definitions": "MetricDefinitionsOperations", - "metrics": "MetricsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py deleted file mode 100644 index 7bbaa65c81e9f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py +++ /dev/null @@ -1,87 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricDefinitionsOperations, MetricsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2018_01_01.operations.MetricDefinitionsOperations - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2018_01_01.operations.MetricsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py deleted file mode 100644 index 30af6193b9be4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py deleted file mode 100644 index 9d4f4ccbcc596..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,87 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricDefinitionsOperations, MetricsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2018_01_01.aio.operations.MetricDefinitionsOperations - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2018_01_01.aio.operations.MetricsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py deleted file mode 100644 index d46ec2816fa2d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._metrics_operations import MetricsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricDefinitionsOperations", - "MetricsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py deleted file mode 100644 index 26fc057e4a010..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_definitions_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_01_01.aio.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_01_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py deleted file mode 100644 index 5c172137628b6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py +++ /dev/null @@ -1,170 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metrics_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_01_01.aio.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, - resource_uri: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - metricnamespace: Optional[str] = None, - **kwargs: Any - ) -> _models.Response: - """**Lists the metric values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: 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'**. Default value is None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: 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' "**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2018_01_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_01_01.models.Response - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) - cls: ClsType[_models.Response] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Response", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py deleted file mode 100644 index f3737db3f5085..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorResponse -from ._models_py3 import LocalizableString -from ._models_py3 import MetadataValue -from ._models_py3 import Metric -from ._models_py3 import MetricAvailability -from ._models_py3 import MetricDefinition -from ._models_py3 import MetricDefinitionCollection -from ._models_py3 import MetricValue -from ._models_py3 import Response -from ._models_py3 import TimeSeriesElement - -from ._monitor_management_client_enums import AggregationType -from ._monitor_management_client_enums import MetricClass -from ._monitor_management_client_enums import MetricUnit -from ._monitor_management_client_enums import ResultType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorResponse", - "LocalizableString", - "MetadataValue", - "Metric", - "MetricAvailability", - "MetricDefinition", - "MetricDefinitionCollection", - "MetricValue", - "Response", - "TimeSeriesElement", - "AggregationType", - "MetricClass", - "MetricUnit", - "ResultType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py deleted file mode 100644 index 88a98ad0be9fb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py +++ /dev/null @@ -1,562 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class LocalizableString(_serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the invariant value. Required. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: the invariant value. Required. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class MetadataValue(_serialization.Model): - """Represents a metric metadata value. - - :ivar name: the name of the metadata. - :vartype name: ~azure.mgmt.monitor.v2018_01_01.models.LocalizableString - :ivar value: the value of the metadata. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "LocalizableString"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__( - self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: the name of the metadata. - :paramtype name: ~azure.mgmt.monitor.v2018_01_01.models.LocalizableString - :keyword value: the value of the metadata. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class Metric(_serialization.Model): - """The result data of a query. - - All required parameters must be populated in order to send to Azure. - - :ivar id: the metric Id. Required. - :vartype id: str - :ivar type: the resource type of the metric resource. Required. - :vartype type: str - :ivar name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :vartype name: ~azure.mgmt.monitor.v2018_01_01.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar error_code: 'Success' or the error details on query failures for this metric. - :vartype error_code: str - :ivar error_message: Error message encountered querying this specific metric. - :vartype error_message: str - :ivar unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2018_01_01.models.MetricUnit - :ivar timeseries: the time series returned when a data query is performed. Required. - :vartype timeseries: list[~azure.mgmt.monitor.v2018_01_01.models.TimeSeriesElement] - """ - - _validation = { - "id": {"required": True}, - "type": {"required": True}, - "name": {"required": True}, - "unit": {"required": True}, - "timeseries": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "timeseries": {"key": "timeseries", "type": "[TimeSeriesElement]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - type: str, - name: "_models.LocalizableString", - unit: Union[str, "_models.MetricUnit"], - timeseries: List["_models.TimeSeriesElement"], - display_description: Optional[str] = None, - error_code: Optional[str] = None, - error_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: the metric Id. Required. - :paramtype id: str - :keyword type: the resource type of the metric resource. Required. - :paramtype type: str - :keyword name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :paramtype name: ~azure.mgmt.monitor.v2018_01_01.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword error_code: 'Success' or the error details on query failures for this metric. - :paramtype error_code: str - :keyword error_message: Error message encountered querying this specific metric. - :paramtype error_message: str - :keyword unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2018_01_01.models.MetricUnit - :keyword timeseries: the time series returned when a data query is performed. Required. - :paramtype timeseries: list[~azure.mgmt.monitor.v2018_01_01.models.TimeSeriesElement] - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.name = name - self.display_description = display_description - self.error_code = error_code - self.error_message = error_message - self.unit = unit - self.timeseries = timeseries - - -class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the - retention period for that time grain. - - :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed - as a duration 'PT1M', 'P1D', etc. - :vartype time_grain: ~datetime.timedelta - :ivar retention: the retention period for the metric at the specified timegrain. Expressed as - a duration 'PT1M', 'P1D', etc. - :vartype retention: ~datetime.timedelta - """ - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "retention": {"key": "retention", "type": "duration"}, - } - - def __init__( - self, - *, - time_grain: Optional[datetime.timedelta] = None, - retention: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the time grain specifies the aggregation interval for the metric. - Expressed as a duration 'PT1M', 'P1D', etc. - :paramtype time_grain: ~datetime.timedelta - :keyword retention: the retention period for the metric at the specified timegrain. Expressed - as a duration 'PT1M', 'P1D', etc. - :paramtype retention: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.retention = retention - - -class MetricDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Metric definition class specifies the metadata for a metric. - - :ivar is_dimension_required: Flag to indicate whether the dimension is required. - :vartype is_dimension_required: bool - :ivar resource_id: the resource identifier of the resource that emitted the metric. - :vartype resource_id: str - :ivar namespace: the namespace the metric belongs to. - :vartype namespace: str - :ivar name: the name and the display name of the metric, i.e. it is a localizable string. - :vartype name: ~azure.mgmt.monitor.v2018_01_01.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar category: Custom category name for this metric. - :vartype category: str - :ivar metric_class: The class of the metric. Known values are: "Availability", "Transactions", - "Errors", "Latency", and "Saturation". - :vartype metric_class: str or ~azure.mgmt.monitor.v2018_01_01.models.MetricClass - :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2018_01_01.models.MetricUnit - :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :vartype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2018_01_01.models.AggregationType - :ivar supported_aggregation_types: the collection of what aggregation types are supported. - :vartype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2018_01_01.models.AggregationType] - :ivar metric_availabilities: the collection of what aggregation intervals are available to be - queried. - :vartype metric_availabilities: list[~azure.mgmt.monitor.v2018_01_01.models.MetricAvailability] - :ivar id: the resource identifier of the metric definition. - :vartype id: str - :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :vartype dimensions: list[~azure.mgmt.monitor.v2018_01_01.models.LocalizableString] - """ - - _attribute_map = { - "is_dimension_required": {"key": "isDimensionRequired", "type": "bool"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "namespace": {"key": "namespace", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "metric_class": {"key": "metricClass", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, - "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, - "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, - "id": {"key": "id", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[LocalizableString]"}, - } - - def __init__( - self, - *, - is_dimension_required: Optional[bool] = None, - resource_id: Optional[str] = None, - namespace: Optional[str] = None, - name: Optional["_models.LocalizableString"] = None, - display_description: Optional[str] = None, - category: Optional[str] = None, - metric_class: Optional[Union[str, "_models.MetricClass"]] = None, - unit: Optional[Union[str, "_models.MetricUnit"]] = None, - primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, - supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, - metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - dimensions: Optional[List["_models.LocalizableString"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_dimension_required: Flag to indicate whether the dimension is required. - :paramtype is_dimension_required: bool - :keyword resource_id: the resource identifier of the resource that emitted the metric. - :paramtype resource_id: str - :keyword namespace: the namespace the metric belongs to. - :paramtype namespace: str - :keyword name: the name and the display name of the metric, i.e. it is a localizable string. - :paramtype name: ~azure.mgmt.monitor.v2018_01_01.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword category: Custom category name for this metric. - :paramtype category: str - :keyword metric_class: The class of the metric. Known values are: "Availability", - "Transactions", "Errors", "Latency", and "Saturation". - :paramtype metric_class: str or ~azure.mgmt.monitor.v2018_01_01.models.MetricClass - :keyword unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2018_01_01.models.MetricUnit - :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :paramtype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2018_01_01.models.AggregationType - :keyword supported_aggregation_types: the collection of what aggregation types are supported. - :paramtype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2018_01_01.models.AggregationType] - :keyword metric_availabilities: the collection of what aggregation intervals are available to - be queried. - :paramtype metric_availabilities: - list[~azure.mgmt.monitor.v2018_01_01.models.MetricAvailability] - :keyword id: the resource identifier of the metric definition. - :paramtype id: str - :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :paramtype dimensions: list[~azure.mgmt.monitor.v2018_01_01.models.LocalizableString] - """ - super().__init__(**kwargs) - self.is_dimension_required = is_dimension_required - self.resource_id = resource_id - self.namespace = namespace - self.name = name - self.display_description = display_description - self.category = category - self.metric_class = metric_class - self.unit = unit - self.primary_aggregation_type = primary_aggregation_type - self.supported_aggregation_types = supported_aggregation_types - self.metric_availabilities = metric_availabilities - self.id = id - self.dimensions = dimensions - - -class MetricDefinitionCollection(_serialization.Model): - """Represents collection of metric definitions. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values for the metric definitions. Required. - :vartype value: list[~azure.mgmt.monitor.v2018_01_01.models.MetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, - } - - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: the values for the metric definitions. Required. - :paramtype value: list[~azure.mgmt.monitor.v2018_01_01.models.MetricDefinition] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricValue(_serialization.Model): - """Represents a metric value. - - All required parameters must be populated in order to send to Azure. - - :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :vartype time_stamp: ~datetime.datetime - :ivar average: the average value in the time range. - :vartype average: float - :ivar minimum: the least value in the time range. - :vartype minimum: float - :ivar maximum: the greatest value in the time range. - :vartype maximum: float - :ivar total: the sum of all of the values in the time range. - :vartype total: float - :ivar count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :vartype count: float - """ - - _validation = { - "time_stamp": {"required": True}, - } - - _attribute_map = { - "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, - "average": {"key": "average", "type": "float"}, - "minimum": {"key": "minimum", "type": "float"}, - "maximum": {"key": "maximum", "type": "float"}, - "total": {"key": "total", "type": "float"}, - "count": {"key": "count", "type": "float"}, - } - - def __init__( - self, - *, - time_stamp: datetime.datetime, - average: Optional[float] = None, - minimum: Optional[float] = None, - maximum: Optional[float] = None, - total: Optional[float] = None, - count: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :paramtype time_stamp: ~datetime.datetime - :keyword average: the average value in the time range. - :paramtype average: float - :keyword minimum: the least value in the time range. - :paramtype minimum: float - :keyword maximum: the greatest value in the time range. - :paramtype maximum: float - :keyword total: the sum of all of the values in the time range. - :paramtype total: float - :keyword count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :paramtype count: float - """ - super().__init__(**kwargs) - self.time_stamp = time_stamp - self.average = average - self.minimum = minimum - self.maximum = maximum - self.total = total - self.count = count - - -class Response(_serialization.Model): - """The response to a metrics query. - - All required parameters must be populated in order to send to Azure. - - :ivar cost: The integer value representing the relative cost of the query. - :vartype cost: int - :ivar timespan: 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. Required. - :vartype timespan: str - :ivar interval: 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. - :vartype interval: ~datetime.timedelta - :ivar namespace: The namespace of the metrics being queried. - :vartype namespace: str - :ivar resourceregion: The region of the resource being queried for metrics. - :vartype resourceregion: str - :ivar value: the value of the collection. Required. - :vartype value: list[~azure.mgmt.monitor.v2018_01_01.models.Metric] - """ - - _validation = { - "cost": {"minimum": 0}, - "timespan": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "cost": {"key": "cost", "type": "int"}, - "timespan": {"key": "timespan", "type": "str"}, - "interval": {"key": "interval", "type": "duration"}, - "namespace": {"key": "namespace", "type": "str"}, - "resourceregion": {"key": "resourceregion", "type": "str"}, - "value": {"key": "value", "type": "[Metric]"}, - } - - def __init__( - self, - *, - timespan: str, - value: List["_models.Metric"], - cost: Optional[int] = None, - interval: Optional[datetime.timedelta] = None, - namespace: Optional[str] = None, - resourceregion: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword cost: The integer value representing the relative cost of the query. - :paramtype cost: int - :keyword timespan: 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. Required. - :paramtype timespan: str - :keyword interval: 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. - :paramtype interval: ~datetime.timedelta - :keyword namespace: The namespace of the metrics being queried. - :paramtype namespace: str - :keyword resourceregion: The region of the resource being queried for metrics. - :paramtype resourceregion: str - :keyword value: the value of the collection. Required. - :paramtype value: list[~azure.mgmt.monitor.v2018_01_01.models.Metric] - """ - super().__init__(**kwargs) - self.cost = cost - self.timespan = timespan - self.interval = interval - self.namespace = namespace - self.resourceregion = resourceregion - self.value = value - - -class TimeSeriesElement(_serialization.Model): - """A time series result type. The discriminator value is always TimeSeries in this case. - - :ivar metadatavalues: the metadata values returned if $filter was specified in the call. - :vartype metadatavalues: list[~azure.mgmt.monitor.v2018_01_01.models.MetadataValue] - :ivar data: An array of data points representing the metric values. This is only returned if a - result type of data is specified. - :vartype data: list[~azure.mgmt.monitor.v2018_01_01.models.MetricValue] - """ - - _attribute_map = { - "metadatavalues": {"key": "metadatavalues", "type": "[MetadataValue]"}, - "data": {"key": "data", "type": "[MetricValue]"}, - } - - def __init__( - self, - *, - metadatavalues: Optional[List["_models.MetadataValue"]] = None, - data: Optional[List["_models.MetricValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword metadatavalues: the metadata values returned if $filter was specified in the call. - :paramtype metadatavalues: list[~azure.mgmt.monitor.v2018_01_01.models.MetadataValue] - :keyword data: An array of data points representing the metric values. This is only returned - if a result type of data is specified. - :paramtype data: list[~azure.mgmt.monitor.v2018_01_01.models.MetricValue] - """ - super().__init__(**kwargs) - self.metadatavalues = metadatavalues - self.data = data diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 5fe91232cac48..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,56 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the aggregation type of the metric.""" - - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - - -class MetricClass(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The class of the metric.""" - - AVAILABILITY = "Availability" - TRANSACTIONS = "Transactions" - ERRORS = "Errors" - LATENCY = "Latency" - SATURATION = "Saturation" - - -class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - PERCENT = "Percent" - MILLI_SECONDS = "MilliSeconds" - BYTE_SECONDS = "ByteSeconds" - UNSPECIFIED = "Unspecified" - CORES = "Cores" - MILLI_CORES = "MilliCores" - NANO_CORES = "NanoCores" - BITS_PER_SECOND = "BitsPerSecond" - - -class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ResultType.""" - - DATA = "Data" - METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py deleted file mode 100644 index d46ec2816fa2d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._metrics_operations import MetricsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricDefinitionsOperations", - "MetricsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py deleted file mode 100644 index e05031c23f5dd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_uri: str, *, metricnamespace: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_01_01.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_01_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py deleted file mode 100644 index 98a050c3c00f7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py +++ /dev/null @@ -1,228 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_uri: str, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - metricnamespace: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metrics") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if timespan is not None: - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - if metricnames is not None: - _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") - if aggregation is not None: - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["orderby"] = _SERIALIZER.query("orderby", orderby, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if result_type is not None: - _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_01_01.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, - resource_uri: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - metricnamespace: Optional[str] = None, - **kwargs: Any - ) -> _models.Response: - """**Lists the metric values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: 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'**. Default value is None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: 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' "**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2018_01_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_01_01.models.Response - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) - cls: ClsType[_models.Response] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Response", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py deleted file mode 100644 index 73b44f979f35a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json deleted file mode 100644 index 4460b40de763b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2018-03-01", - "total_api_version_list": ["2018-03-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations", - "metric_alerts": "MetricAlertsOperations", - "metric_alerts_status": "MetricAlertsStatusOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py deleted file mode 100644 index 57c2ad3707253..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2018_03_01.operations.ActionGroupsOperations - :ivar metric_alerts: MetricAlertsOperations operations - :vartype metric_alerts: azure.mgmt.monitor.v2018_03_01.operations.MetricAlertsOperations - :ivar metric_alerts_status: MetricAlertsStatusOperations operations - :vartype metric_alerts_status: - azure.mgmt.monitor.v2018_03_01.operations.MetricAlertsStatusOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts_status = MetricAlertsStatusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py deleted file mode 100644 index 9b7f0bc7ffb42..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py deleted file mode 100644 index 73cd9dbc61789..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2018_03_01.aio.operations.ActionGroupsOperations - :ivar metric_alerts: MetricAlertsOperations operations - :vartype metric_alerts: azure.mgmt.monitor.v2018_03_01.aio.operations.MetricAlertsOperations - :ivar metric_alerts_status: MetricAlertsStatusOperations operations - :vartype metric_alerts_status: - azure.mgmt.monitor.v2018_03_01.aio.operations.MetricAlertsStatusOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts_status = MetricAlertsStatusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py deleted file mode 100644 index 854cfe54a91d0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._metric_alerts_operations import MetricAlertsOperations -from ._metric_alerts_status_operations import MetricAlertsStatusOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "MetricAlertsOperations", - "MetricAlertsStatusOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index 5e6c3dd5956c3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,792 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_03_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2018_03_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2018_03_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py deleted file mode 100644 index 3a7754a8b6fa6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py +++ /dev/null @@ -1,643 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_alerts_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_03_01.aio.MonitorManagementClient`'s - :attr:`metric_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.MetricAlertResource"]: - """Retrieve alert rule definitions in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricAlertResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.MetricAlertResource"]: - """Retrieve alert rule definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricAlertResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: - """Retrieve an alert rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.MetricAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Create or update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Create or update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.MetricAlertResource, IO], - **kwargs: Any - ) -> _models.MetricAlertResource: - """Create or update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - MetricAlertResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MetricAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.MetricAlertResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.MetricAlertResourcePatch, IO], - **kwargs: Any - ) -> _models.MetricAlertResource: - """Update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a MetricAlertResourcePatch - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MetricAlertResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Delete an alert rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py deleted file mode 100644 index 356ee548b29c9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_alerts_status_operations import build_list_by_name_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricAlertsStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_03_01.aio.MonitorManagementClient`'s - :attr:`metric_alerts_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list( - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> _models.MetricAlertStatusCollection: - """Retrieve an alert rule status. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatusCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status" - } - - @distributed_trace_async - async def list_by_name( - self, resource_group_name: str, rule_name: str, status_name: str, **kwargs: Any - ) -> _models.MetricAlertStatusCollection: - """Retrieve an alert rule status. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param status_name: The name of the status. Required. - :type status_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatusCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) - - request = build_list_by_name_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - status_name=status_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_name.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py deleted file mode 100644 index 8dd7a2ac99a2e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py +++ /dev/null @@ -1,93 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import DynamicMetricCriteria -from ._models_py3 import DynamicThresholdFailingPeriods -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import ItsmReceiver -from ._models_py3 import LogicAppReceiver -from ._models_py3 import MetricAlertAction -from ._models_py3 import MetricAlertCriteria -from ._models_py3 import MetricAlertMultipleResourceMultipleMetricCriteria -from ._models_py3 import MetricAlertResource -from ._models_py3 import MetricAlertResourceCollection -from ._models_py3 import MetricAlertResourcePatch -from ._models_py3 import MetricAlertSingleResourceMultipleMetricCriteria -from ._models_py3 import MetricAlertStatus -from ._models_py3 import MetricAlertStatusCollection -from ._models_py3 import MetricAlertStatusProperties -from ._models_py3 import MetricCriteria -from ._models_py3 import MetricDimension -from ._models_py3 import MultiMetricCriteria -from ._models_py3 import Resource -from ._models_py3 import SmsReceiver -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver -from ._models_py3 import WebtestLocationAvailabilityCriteria - -from ._monitor_management_client_enums import AggregationTypeEnum -from ._monitor_management_client_enums import CriterionType -from ._monitor_management_client_enums import DynamicThresholdOperator -from ._monitor_management_client_enums import DynamicThresholdSensitivity -from ._monitor_management_client_enums import Odatatype -from ._monitor_management_client_enums import Operator -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "DynamicMetricCriteria", - "DynamicThresholdFailingPeriods", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "ItsmReceiver", - "LogicAppReceiver", - "MetricAlertAction", - "MetricAlertCriteria", - "MetricAlertMultipleResourceMultipleMetricCriteria", - "MetricAlertResource", - "MetricAlertResourceCollection", - "MetricAlertResourcePatch", - "MetricAlertSingleResourceMultipleMetricCriteria", - "MetricAlertStatus", - "MetricAlertStatusCollection", - "MetricAlertStatusProperties", - "MetricCriteria", - "MetricDimension", - "MultiMetricCriteria", - "Resource", - "SmsReceiver", - "VoiceReceiver", - "WebhookReceiver", - "WebtestLocationAvailabilityCriteria", - "AggregationTypeEnum", - "CriterionType", - "DynamicThresholdOperator", - "DynamicThresholdSensitivity", - "Odatatype", - "Operator", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py deleted file mode 100644 index d842e635ffddd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py +++ /dev/null @@ -1,1840 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(Resource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2018_03_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2018_03_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2018_03_01.models.AzureFunctionReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2018_03_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2018_03_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2018_03_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2018_03_01.models.AzureFunctionReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - } - - def __init__( - self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - - -class MultiMetricCriteria(_serialization.Model): - """The types of conditions for a multi resource alert. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - DynamicMetricCriteria, MetricCriteria - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: - "StaticThresholdCriterion" and "DynamicThresholdCriterion". - :vartype criterion_type: str or ~azure.mgmt.monitor.v2018_03_01.models.CriterionType - :ivar name: Name of the criteria. Required. - :vartype name: str - :ivar metric_name: Name of the metric. Required. - :vartype metric_name: str - :ivar metric_namespace: Namespace of the metric. - :vartype metric_namespace: str - :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: - "Average", "Count", "Minimum", "Maximum", and "Total". - :vartype time_aggregation: str or ~azure.mgmt.monitor.v2018_03_01.models.AggregationTypeEnum - :ivar dimensions: List of dimension conditions. - :vartype dimensions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricDimension] - :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet - emitted, by causing the metric validation to be skipped. - :vartype skip_metric_validation: bool - """ - - _validation = { - "criterion_type": {"required": True}, - "name": {"required": True}, - "metric_name": {"required": True}, - "time_aggregation": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "criterion_type": {"key": "criterionType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "metric_name": {"key": "metricName", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, - "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, - } - - _subtype_map = { - "criterion_type": { - "DynamicThresholdCriterion": "DynamicMetricCriteria", - "StaticThresholdCriterion": "MetricCriteria", - } - } - - def __init__( - self, - *, - name: str, - metric_name: str, - time_aggregation: Union[str, "_models.AggregationTypeEnum"], - additional_properties: Optional[Dict[str, JSON]] = None, - metric_namespace: Optional[str] = None, - dimensions: Optional[List["_models.MetricDimension"]] = None, - skip_metric_validation: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - :keyword name: Name of the criteria. Required. - :paramtype name: str - :keyword metric_name: Name of the metric. Required. - :paramtype metric_name: str - :keyword metric_namespace: Namespace of the metric. - :paramtype metric_namespace: str - :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: - "Average", "Count", "Minimum", "Maximum", and "Total". - :paramtype time_aggregation: str or ~azure.mgmt.monitor.v2018_03_01.models.AggregationTypeEnum - :keyword dimensions: List of dimension conditions. - :paramtype dimensions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricDimension] - :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't - yet emitted, by causing the metric validation to be skipped. - :paramtype skip_metric_validation: bool - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.criterion_type: Optional[str] = None - self.name = name - self.metric_name = metric_name - self.metric_namespace = metric_namespace - self.time_aggregation = time_aggregation - self.dimensions = dimensions - self.skip_metric_validation = skip_metric_validation - - -class DynamicMetricCriteria(MultiMetricCriteria): # pylint: disable=too-many-instance-attributes - """Criterion for dynamic threshold. - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: - "StaticThresholdCriterion" and "DynamicThresholdCriterion". - :vartype criterion_type: str or ~azure.mgmt.monitor.v2018_03_01.models.CriterionType - :ivar name: Name of the criteria. Required. - :vartype name: str - :ivar metric_name: Name of the metric. Required. - :vartype metric_name: str - :ivar metric_namespace: Namespace of the metric. - :vartype metric_namespace: str - :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: - "Average", "Count", "Minimum", "Maximum", and "Total". - :vartype time_aggregation: str or ~azure.mgmt.monitor.v2018_03_01.models.AggregationTypeEnum - :ivar dimensions: List of dimension conditions. - :vartype dimensions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricDimension] - :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet - emitted, by causing the metric validation to be skipped. - :vartype skip_metric_validation: bool - :ivar operator: The operator used to compare the metric value against the threshold. Required. - Known values are: "GreaterThan", "LessThan", and "GreaterOrLessThan". - :vartype operator: str or ~azure.mgmt.monitor.v2018_03_01.models.DynamicThresholdOperator - :ivar alert_sensitivity: The extent of deviation required to trigger an alert. This will affect - how tight the threshold is to the metric series pattern. Required. Known values are: "Low", - "Medium", and "High". - :vartype alert_sensitivity: str or - ~azure.mgmt.monitor.v2018_03_01.models.DynamicThresholdSensitivity - :ivar failing_periods: The minimum number of violations required within the selected lookback - time window required to raise an alert. Required. - :vartype failing_periods: ~azure.mgmt.monitor.v2018_03_01.models.DynamicThresholdFailingPeriods - :ivar ignore_data_before: Use this option to set the date from which to start learning the - metric historical data and calculate the dynamic thresholds (in ISO8601 format). - :vartype ignore_data_before: ~datetime.datetime - """ - - _validation = { - "criterion_type": {"required": True}, - "name": {"required": True}, - "metric_name": {"required": True}, - "time_aggregation": {"required": True}, - "operator": {"required": True}, - "alert_sensitivity": {"required": True}, - "failing_periods": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "criterion_type": {"key": "criterionType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "metric_name": {"key": "metricName", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, - "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, - "operator": {"key": "operator", "type": "str"}, - "alert_sensitivity": {"key": "alertSensitivity", "type": "str"}, - "failing_periods": {"key": "failingPeriods", "type": "DynamicThresholdFailingPeriods"}, - "ignore_data_before": {"key": "ignoreDataBefore", "type": "iso-8601"}, - } - - def __init__( - self, - *, - name: str, - metric_name: str, - time_aggregation: Union[str, "_models.AggregationTypeEnum"], - operator: Union[str, "_models.DynamicThresholdOperator"], - alert_sensitivity: Union[str, "_models.DynamicThresholdSensitivity"], - failing_periods: "_models.DynamicThresholdFailingPeriods", - additional_properties: Optional[Dict[str, JSON]] = None, - metric_namespace: Optional[str] = None, - dimensions: Optional[List["_models.MetricDimension"]] = None, - skip_metric_validation: Optional[bool] = None, - ignore_data_before: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - :keyword name: Name of the criteria. Required. - :paramtype name: str - :keyword metric_name: Name of the metric. Required. - :paramtype metric_name: str - :keyword metric_namespace: Namespace of the metric. - :paramtype metric_namespace: str - :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: - "Average", "Count", "Minimum", "Maximum", and "Total". - :paramtype time_aggregation: str or ~azure.mgmt.monitor.v2018_03_01.models.AggregationTypeEnum - :keyword dimensions: List of dimension conditions. - :paramtype dimensions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricDimension] - :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't - yet emitted, by causing the metric validation to be skipped. - :paramtype skip_metric_validation: bool - :keyword operator: The operator used to compare the metric value against the threshold. - Required. Known values are: "GreaterThan", "LessThan", and "GreaterOrLessThan". - :paramtype operator: str or ~azure.mgmt.monitor.v2018_03_01.models.DynamicThresholdOperator - :keyword alert_sensitivity: The extent of deviation required to trigger an alert. This will - affect how tight the threshold is to the metric series pattern. Required. Known values are: - "Low", "Medium", and "High". - :paramtype alert_sensitivity: str or - ~azure.mgmt.monitor.v2018_03_01.models.DynamicThresholdSensitivity - :keyword failing_periods: The minimum number of violations required within the selected - lookback time window required to raise an alert. Required. - :paramtype failing_periods: - ~azure.mgmt.monitor.v2018_03_01.models.DynamicThresholdFailingPeriods - :keyword ignore_data_before: Use this option to set the date from which to start learning the - metric historical data and calculate the dynamic thresholds (in ISO8601 format). - :paramtype ignore_data_before: ~datetime.datetime - """ - super().__init__( - additional_properties=additional_properties, - name=name, - metric_name=metric_name, - metric_namespace=metric_namespace, - time_aggregation=time_aggregation, - dimensions=dimensions, - skip_metric_validation=skip_metric_validation, - **kwargs - ) - self.criterion_type: str = "DynamicThresholdCriterion" - self.operator = operator - self.alert_sensitivity = alert_sensitivity - self.failing_periods = failing_periods - self.ignore_data_before = ignore_data_before - - -class DynamicThresholdFailingPeriods(_serialization.Model): - """The minimum number of violations required within the selected lookback time window required to - raise an alert. - - All required parameters must be populated in order to send to Azure. - - :ivar number_of_evaluation_periods: 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. Required. - :vartype number_of_evaluation_periods: float - :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be - smaller or equal to numberOfEvaluationPeriods. Required. - :vartype min_failing_periods_to_alert: float - """ - - _validation = { - "number_of_evaluation_periods": {"required": True}, - "min_failing_periods_to_alert": {"required": True}, - } - - _attribute_map = { - "number_of_evaluation_periods": {"key": "numberOfEvaluationPeriods", "type": "float"}, - "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "float"}, - } - - def __init__( - self, *, number_of_evaluation_periods: float, min_failing_periods_to_alert: float, **kwargs: Any - ) -> None: - """ - :keyword number_of_evaluation_periods: 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. Required. - :paramtype number_of_evaluation_periods: float - :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be - smaller or equal to numberOfEvaluationPeriods. Required. - :paramtype min_failing_periods_to_alert: float - """ - super().__init__(**kwargs) - self.number_of_evaluation_periods = number_of_evaluation_periods - self.min_failing_periods_to_alert = min_failing_periods_to_alert - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2018_03_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - } - - def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - - -class MetricAlertAction(_serialization.Model): - """An alert action. - - :ivar action_group_id: the id of the action group to use. - :vartype action_group_id: str - :ivar web_hook_properties: This field allows specifying custom properties, which would be - appended to the alert payload sent as input to the webhook. - :vartype web_hook_properties: dict[str, str] - """ - - _attribute_map = { - "action_group_id": {"key": "actionGroupId", "type": "str"}, - "web_hook_properties": {"key": "webHookProperties", "type": "{str}"}, - } - - def __init__( - self, - *, - action_group_id: Optional[str] = None, - web_hook_properties: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword action_group_id: the id of the action group to use. - :paramtype action_group_id: str - :keyword web_hook_properties: This field allows specifying custom properties, which would be - appended to the alert payload sent as input to the webhook. - :paramtype web_hook_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.action_group_id = action_group_id - self.web_hook_properties = web_hook_properties - - -class MetricAlertCriteria(_serialization.Model): - """The rule criteria that defines the conditions of the alert rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - MetricAlertMultipleResourceMultipleMetricCriteria, - MetricAlertSingleResourceMultipleMetricCriteria, WebtestLocationAvailabilityCriteria - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and - "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :vartype odata_type: str or ~azure.mgmt.monitor.v2018_03_01.models.Odatatype - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "odata_type": {"key": "odata\\.type", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria": "MetricAlertMultipleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria": "MetricAlertSingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria": "WebtestLocationAvailabilityCriteria", - } - } - - def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.odata_type: Optional[str] = None - - -class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): - """Specifies the metric alert criteria for multiple resource that has multiple metric criteria. - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and - "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :vartype odata_type: str or ~azure.mgmt.monitor.v2018_03_01.models.Odatatype - :ivar all_of: the list of multiple metric criteria for this 'all of' operation. - :vartype all_of: list[~azure.mgmt.monitor.v2018_03_01.models.MultiMetricCriteria] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "odata_type": {"key": "odata\\.type", "type": "str"}, - "all_of": {"key": "allOf", "type": "[MultiMetricCriteria]"}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, JSON]] = None, - all_of: Optional[List["_models.MultiMetricCriteria"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - :keyword all_of: the list of multiple metric criteria for this 'all of' operation. - :paramtype all_of: list[~azure.mgmt.monitor.v2018_03_01.models.MultiMetricCriteria] - """ - super().__init__(additional_properties=additional_properties, **kwargs) - self.odata_type: str = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" - self.all_of = all_of - - -class MetricAlertResource(Resource): # pylint: disable=too-many-instance-attributes - """The metric alert resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar description: the description of the metric alert that will be included in the alert - email. - :vartype description: str - :ivar severity: Alert severity {0, 1, 2, 3, 4}. Required. - :vartype severity: int - :ivar enabled: the flag that indicates whether the metric alert is enabled. Required. - :vartype enabled: bool - :ivar scopes: the list of resource id's that this metric alert is scoped to. Required. - :vartype scopes: list[str] - :ivar evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 - duration format. Required. - :vartype evaluation_frequency: ~datetime.timedelta - :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor - alert activity based on the threshold. Required. - :vartype window_size: ~datetime.timedelta - :ivar target_resource_type: 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. - :vartype target_resource_type: str - :ivar target_resource_region: 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. - :vartype target_resource_region: str - :ivar criteria: defines the specific alert criteria information. Required. - :vartype criteria: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertCriteria - :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. - The default is true. - :vartype auto_mitigate: bool - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - :ivar is_migrated: the value indicating whether this alert rule is migrated. - :vartype is_migrated: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "severity": {"required": True}, - "enabled": {"required": True}, - "scopes": {"required": True}, - "evaluation_frequency": {"required": True}, - "window_size": {"required": True}, - "criteria": {"required": True}, - "last_updated_time": {"readonly": True}, - "is_migrated": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "severity": {"key": "properties.severity", "type": "int"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, - "window_size": {"key": "properties.windowSize", "type": "duration"}, - "target_resource_type": {"key": "properties.targetResourceType", "type": "str"}, - "target_resource_region": {"key": "properties.targetResourceRegion", "type": "str"}, - "criteria": {"key": "properties.criteria", "type": "MetricAlertCriteria"}, - "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, - "actions": {"key": "properties.actions", "type": "[MetricAlertAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - "is_migrated": {"key": "properties.isMigrated", "type": "bool"}, - } - - def __init__( - self, - *, - location: str, - severity: int, - enabled: bool, - scopes: List[str], - evaluation_frequency: datetime.timedelta, - window_size: datetime.timedelta, - criteria: "_models.MetricAlertCriteria", - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - target_resource_type: Optional[str] = None, - target_resource_region: Optional[str] = None, - auto_mitigate: Optional[bool] = None, - actions: Optional[List["_models.MetricAlertAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: the description of the metric alert that will be included in the alert - email. - :paramtype description: str - :keyword severity: Alert severity {0, 1, 2, 3, 4}. Required. - :paramtype severity: int - :keyword enabled: the flag that indicates whether the metric alert is enabled. Required. - :paramtype enabled: bool - :keyword scopes: the list of resource id's that this metric alert is scoped to. Required. - :paramtype scopes: list[str] - :keyword evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 - duration format. Required. - :paramtype evaluation_frequency: ~datetime.timedelta - :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor - alert activity based on the threshold. Required. - :paramtype window_size: ~datetime.timedelta - :keyword target_resource_type: 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. - :paramtype target_resource_type: str - :keyword target_resource_region: 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. - :paramtype target_resource_region: str - :keyword criteria: defines the specific alert criteria information. Required. - :paramtype criteria: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertCriteria - :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or - not. The default is true. - :paramtype auto_mitigate: bool - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertAction] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.description = description - self.severity = severity - self.enabled = enabled - self.scopes = scopes - self.evaluation_frequency = evaluation_frequency - self.window_size = window_size - self.target_resource_type = target_resource_type - self.target_resource_region = target_resource_region - self.criteria = criteria - self.auto_mitigate = auto_mitigate - self.actions = actions - self.last_updated_time = None - self.is_migrated = None - - -class MetricAlertResourceCollection(_serialization.Model): - """Represents a collection of alert rule resources. - - :ivar value: the values for the alert rule resources. - :vartype value: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[MetricAlertResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.MetricAlertResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: the values for the alert rule resources. - :paramtype value: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricAlertResourcePatch(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The metric alert resource for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar description: the description of the metric alert that will be included in the alert - email. - :vartype description: str - :ivar severity: Alert severity {0, 1, 2, 3, 4}. - :vartype severity: int - :ivar enabled: the flag that indicates whether the metric alert is enabled. - :vartype enabled: bool - :ivar scopes: the list of resource id's that this metric alert is scoped to. - :vartype scopes: list[str] - :ivar evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 - duration format. - :vartype evaluation_frequency: ~datetime.timedelta - :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor - alert activity based on the threshold. - :vartype window_size: ~datetime.timedelta - :ivar target_resource_type: the resource type of the target resource(s) on which the alert is - created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :vartype target_resource_type: str - :ivar target_resource_region: the region of the target resource(s) on which the alert is - created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :vartype target_resource_region: str - :ivar criteria: defines the specific alert criteria information. - :vartype criteria: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertCriteria - :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. - The default is true. - :vartype auto_mitigate: bool - :ivar actions: the array of actions that are performed when the alert rule becomes active, and - when an alert condition is resolved. - :vartype actions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertAction] - :ivar last_updated_time: Last time the rule was updated in ISO8601 format. - :vartype last_updated_time: ~datetime.datetime - :ivar is_migrated: the value indicating whether this alert rule is migrated. - :vartype is_migrated: bool - """ - - _validation = { - "last_updated_time": {"readonly": True}, - "is_migrated": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "description": {"key": "properties.description", "type": "str"}, - "severity": {"key": "properties.severity", "type": "int"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, - "window_size": {"key": "properties.windowSize", "type": "duration"}, - "target_resource_type": {"key": "properties.targetResourceType", "type": "str"}, - "target_resource_region": {"key": "properties.targetResourceRegion", "type": "str"}, - "criteria": {"key": "properties.criteria", "type": "MetricAlertCriteria"}, - "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, - "actions": {"key": "properties.actions", "type": "[MetricAlertAction]"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - "is_migrated": {"key": "properties.isMigrated", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - severity: Optional[int] = None, - enabled: Optional[bool] = None, - scopes: Optional[List[str]] = None, - evaluation_frequency: Optional[datetime.timedelta] = None, - window_size: Optional[datetime.timedelta] = None, - target_resource_type: Optional[str] = None, - target_resource_region: Optional[str] = None, - criteria: Optional["_models.MetricAlertCriteria"] = None, - auto_mitigate: Optional[bool] = None, - actions: Optional[List["_models.MetricAlertAction"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: the description of the metric alert that will be included in the alert - email. - :paramtype description: str - :keyword severity: Alert severity {0, 1, 2, 3, 4}. - :paramtype severity: int - :keyword enabled: the flag that indicates whether the metric alert is enabled. - :paramtype enabled: bool - :keyword scopes: the list of resource id's that this metric alert is scoped to. - :paramtype scopes: list[str] - :keyword evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 - duration format. - :paramtype evaluation_frequency: ~datetime.timedelta - :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor - alert activity based on the threshold. - :paramtype window_size: ~datetime.timedelta - :keyword target_resource_type: the resource type of the target resource(s) on which the alert - is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :paramtype target_resource_type: str - :keyword target_resource_region: the region of the target resource(s) on which the alert is - created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :paramtype target_resource_region: str - :keyword criteria: defines the specific alert criteria information. - :paramtype criteria: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertCriteria - :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or - not. The default is true. - :paramtype auto_mitigate: bool - :keyword actions: the array of actions that are performed when the alert rule becomes active, - and when an alert condition is resolved. - :paramtype actions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertAction] - """ - super().__init__(**kwargs) - self.tags = tags - self.description = description - self.severity = severity - self.enabled = enabled - self.scopes = scopes - self.evaluation_frequency = evaluation_frequency - self.window_size = window_size - self.target_resource_type = target_resource_type - self.target_resource_region = target_resource_region - self.criteria = criteria - self.auto_mitigate = auto_mitigate - self.actions = actions - self.last_updated_time = None - self.is_migrated = None - - -class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): - """Specifies the metric alert criteria for a single resource that has multiple metric criteria. - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and - "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :vartype odata_type: str or ~azure.mgmt.monitor.v2018_03_01.models.Odatatype - :ivar all_of: The list of metric criteria for this 'all of' operation. - :vartype all_of: list[~azure.mgmt.monitor.v2018_03_01.models.MetricCriteria] - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "odata_type": {"key": "odata\\.type", "type": "str"}, - "all_of": {"key": "allOf", "type": "[MetricCriteria]"}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, JSON]] = None, - all_of: Optional[List["_models.MetricCriteria"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - :keyword all_of: The list of metric criteria for this 'all of' operation. - :paramtype all_of: list[~azure.mgmt.monitor.v2018_03_01.models.MetricCriteria] - """ - super().__init__(additional_properties=additional_properties, **kwargs) - self.odata_type: str = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" - self.all_of = all_of - - -class MetricAlertStatus(_serialization.Model): - """An alert status. - - :ivar name: The status name. - :vartype name: str - :ivar id: The alert rule arm id. - :vartype id: str - :ivar type: The extended resource type name. - :vartype type: str - :ivar properties: The alert status properties of the metric alert status. - :vartype properties: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatusProperties - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "MetricAlertStatusProperties"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - type: Optional[str] = None, - properties: Optional["_models.MetricAlertStatusProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The status name. - :paramtype name: str - :keyword id: The alert rule arm id. - :paramtype id: str - :keyword type: The extended resource type name. - :paramtype type: str - :keyword properties: The alert status properties of the metric alert status. - :paramtype properties: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatusProperties - """ - super().__init__(**kwargs) - self.name = name - self.id = id - self.type = type - self.properties = properties - - -class MetricAlertStatusCollection(_serialization.Model): - """Represents a collection of alert rule resources. - - :ivar value: the values for the alert rule resources. - :vartype value: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatus] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[MetricAlertStatus]"}, - } - - def __init__(self, *, value: Optional[List["_models.MetricAlertStatus"]] = None, **kwargs: Any) -> None: - """ - :keyword value: the values for the alert rule resources. - :paramtype value: list[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatus] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricAlertStatusProperties(_serialization.Model): - """An alert status properties. - - :ivar dimensions: An object describing the type of the dimensions. - :vartype dimensions: dict[str, str] - :ivar status: status value. - :vartype status: str - :ivar timestamp: UTC time when the status was checked. - :vartype timestamp: ~datetime.datetime - """ - - _attribute_map = { - "dimensions": {"key": "dimensions", "type": "{str}"}, - "status": {"key": "status", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - } - - def __init__( - self, - *, - dimensions: Optional[Dict[str, str]] = None, - status: Optional[str] = None, - timestamp: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword dimensions: An object describing the type of the dimensions. - :paramtype dimensions: dict[str, str] - :keyword status: status value. - :paramtype status: str - :keyword timestamp: UTC time when the status was checked. - :paramtype timestamp: ~datetime.datetime - """ - super().__init__(**kwargs) - self.dimensions = dimensions - self.status = status - self.timestamp = timestamp - - -class MetricCriteria(MultiMetricCriteria): - """Criterion to filter metrics. - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar criterion_type: Specifies the type of threshold criteria. Required. Known values are: - "StaticThresholdCriterion" and "DynamicThresholdCriterion". - :vartype criterion_type: str or ~azure.mgmt.monitor.v2018_03_01.models.CriterionType - :ivar name: Name of the criteria. Required. - :vartype name: str - :ivar metric_name: Name of the metric. Required. - :vartype metric_name: str - :ivar metric_namespace: Namespace of the metric. - :vartype metric_namespace: str - :ivar time_aggregation: the criteria time aggregation types. Required. Known values are: - "Average", "Count", "Minimum", "Maximum", and "Total". - :vartype time_aggregation: str or ~azure.mgmt.monitor.v2018_03_01.models.AggregationTypeEnum - :ivar dimensions: List of dimension conditions. - :vartype dimensions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricDimension] - :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet - emitted, by causing the metric validation to be skipped. - :vartype skip_metric_validation: bool - :ivar operator: the criteria operator. Required. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2018_03_01.models.Operator - :ivar threshold: the criteria threshold value that activates the alert. Required. - :vartype threshold: float - """ - - _validation = { - "criterion_type": {"required": True}, - "name": {"required": True}, - "metric_name": {"required": True}, - "time_aggregation": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "criterion_type": {"key": "criterionType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "metric_name": {"key": "metricName", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, - "skip_metric_validation": {"key": "skipMetricValidation", "type": "bool"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - } - - def __init__( - self, - *, - name: str, - metric_name: str, - time_aggregation: Union[str, "_models.AggregationTypeEnum"], - operator: Union[str, "_models.Operator"], - threshold: float, - additional_properties: Optional[Dict[str, JSON]] = None, - metric_namespace: Optional[str] = None, - dimensions: Optional[List["_models.MetricDimension"]] = None, - skip_metric_validation: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - :keyword name: Name of the criteria. Required. - :paramtype name: str - :keyword metric_name: Name of the metric. Required. - :paramtype metric_name: str - :keyword metric_namespace: Namespace of the metric. - :paramtype metric_namespace: str - :keyword time_aggregation: the criteria time aggregation types. Required. Known values are: - "Average", "Count", "Minimum", "Maximum", and "Total". - :paramtype time_aggregation: str or ~azure.mgmt.monitor.v2018_03_01.models.AggregationTypeEnum - :keyword dimensions: List of dimension conditions. - :paramtype dimensions: list[~azure.mgmt.monitor.v2018_03_01.models.MetricDimension] - :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't - yet emitted, by causing the metric validation to be skipped. - :paramtype skip_metric_validation: bool - :keyword operator: the criteria operator. Required. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2018_03_01.models.Operator - :keyword threshold: the criteria threshold value that activates the alert. Required. - :paramtype threshold: float - """ - super().__init__( - additional_properties=additional_properties, - name=name, - metric_name=metric_name, - metric_namespace=metric_namespace, - time_aggregation=time_aggregation, - dimensions=dimensions, - skip_metric_validation=skip_metric_validation, - **kwargs - ) - self.criterion_type: str = "StaticThresholdCriterion" - self.operator = operator - self.threshold = threshold - - -class MetricDimension(_serialization.Model): - """Specifies a metric dimension. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the dimension. Required. - :vartype name: str - :ivar operator: the dimension operator. Only 'Include' and 'Exclude' are supported. Required. - :vartype operator: str - :ivar values: list of dimension values. Required. - :vartype values: list[str] - """ - - _validation = { - "name": {"required": True}, - "operator": {"required": True}, - "values": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - } - - def __init__(self, *, name: str, operator: str, values: List[str], **kwargs: Any) -> None: - """ - :keyword name: Name of the dimension. Required. - :paramtype name: str - :keyword operator: the dimension operator. Only 'Include' and 'Exclude' are supported. - Required. - :paramtype operator: str - :keyword values: list of dimension values. Required. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.operator = operator - self.values = values - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2018_03_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - } - - def __init__(self, *, name: str, service_uri: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - - -class WebtestLocationAvailabilityCriteria(MetricAlertCriteria): - """Specifies the metric alert rule criteria for a web test resource. - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, JSON] - :ivar odata_type: specifies the type of the alert criteria. Required. Known values are: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", and - "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :vartype odata_type: str or ~azure.mgmt.monitor.v2018_03_01.models.Odatatype - :ivar web_test_id: The Application Insights web test Id. Required. - :vartype web_test_id: str - :ivar component_id: The Application Insights resource Id. Required. - :vartype component_id: str - :ivar failed_location_count: The number of failed locations. Required. - :vartype failed_location_count: float - """ - - _validation = { - "odata_type": {"required": True}, - "web_test_id": {"required": True}, - "component_id": {"required": True}, - "failed_location_count": {"required": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "odata_type": {"key": "odata\\.type", "type": "str"}, - "web_test_id": {"key": "webTestId", "type": "str"}, - "component_id": {"key": "componentId", "type": "str"}, - "failed_location_count": {"key": "failedLocationCount", "type": "float"}, - } - - def __init__( - self, - *, - web_test_id: str, - component_id: str, - failed_location_count: float, - additional_properties: Optional[Dict[str, JSON]] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, JSON] - :keyword web_test_id: The Application Insights web test Id. Required. - :paramtype web_test_id: str - :keyword component_id: The Application Insights resource Id. Required. - :paramtype component_id: str - :keyword failed_location_count: The number of failed locations. Required. - :paramtype failed_location_count: float - """ - super().__init__(additional_properties=additional_properties, **kwargs) - self.odata_type: str = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" - self.web_test_id = web_test_id - self.component_id = component_id - self.failed_location_count = failed_location_count diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 2310232dcd2f7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregationTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the criteria time aggregation types.""" - - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - - -class CriterionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the type of threshold criteria.""" - - STATIC_THRESHOLD_CRITERION = "StaticThresholdCriterion" - DYNAMIC_THRESHOLD_CRITERION = "DynamicThresholdCriterion" - - -class DynamicThresholdOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operator used to compare the metric value against the threshold.""" - - GREATER_THAN = "GreaterThan" - LESS_THAN = "LessThan" - GREATER_OR_LESS_THAN = "GreaterOrLessThan" - - -class DynamicThresholdSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The extent of deviation required to trigger an alert. This will affect how tight the threshold - is to the metric series pattern. - """ - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - - -class Odatatype(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """specifies the type of the alert criteria.""" - - MICROSOFT_AZURE_MONITOR_SINGLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = ( - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" - ) - MICROSOFT_AZURE_MONITOR_MULTIPLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = ( - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" - ) - MICROSOFT_AZURE_MONITOR_WEBTEST_LOCATION_AVAILABILITY_CRITERIA = ( - "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" - ) - - -class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the criteria operator.""" - - EQUALS = "Equals" - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py deleted file mode 100644 index 854cfe54a91d0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._metric_alerts_operations import MetricAlertsOperations -from ._metric_alerts_status_operations import MetricAlertsStatusOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "MetricAlertsOperations", - "MetricAlertsStatusOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py deleted file mode 100644 index 8940343c2b868..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,1014 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_03_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2018_03_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2018_03_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py deleted file mode 100644 index 9e32945a64e1b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py +++ /dev/null @@ -1,824 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_03_01.MonitorManagementClient`'s - :attr:`metric_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.MetricAlertResource"]: - """Retrieve alert rule definitions in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricAlertResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.MetricAlertResource"]: - """Retrieve alert rule definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricAlertResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts" - } - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: - """Retrieve an alert rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.MetricAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Create or update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Create or update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.MetricAlertResource, IO], - **kwargs: Any - ) -> _models.MetricAlertResource: - """Create or update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - MetricAlertResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MetricAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.MetricAlertResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.MetricAlertResource: - """Update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.MetricAlertResourcePatch, IO], - **kwargs: Any - ) -> _models.MetricAlertResource: - """Update an metric alert definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a MetricAlertResourcePatch - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "MetricAlertResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Delete an alert rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py deleted file mode 100644 index 95fde4631f7c6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py +++ /dev/null @@ -1,250 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_name_request( - resource_group_name: str, rule_name: str, status_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "statusName": _SERIALIZER.url("status_name", status_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricAlertsStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_03_01.MonitorManagementClient`'s - :attr:`metric_alerts_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertStatusCollection: - """Retrieve an alert rule status. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatusCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) - - request = build_list_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status" - } - - @distributed_trace - def list_by_name( - self, resource_group_name: str, rule_name: str, status_name: str, **kwargs: Any - ) -> _models.MetricAlertStatusCollection: - """Retrieve an alert rule status. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param status_name: The name of the status. Required. - :type status_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetricAlertStatusCollection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_03_01.models.MetricAlertStatusCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) - cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) - - request = build_list_by_name_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - status_name=status_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_name.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricAlertStatusCollection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py deleted file mode 100644 index c762f34e7a72b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-04-16") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json deleted file mode 100644 index 23673fec14349..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2018-04-16", - "total_api_version_list": ["2018-04-16"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "scheduled_query_rules": "ScheduledQueryRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py deleted file mode 100644 index c022f2b49f74f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: - azure.mgmt.monitor.v2018_04_16.operations.ScheduledQueryRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py deleted file mode 100644 index 9b10881a577b5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-04-16") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py deleted file mode 100644 index b8dca5d39113e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: - azure.mgmt.monitor.v2018_04_16.aio.operations.ScheduledQueryRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py deleted file mode 100644 index e010c281d4fc5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ScheduledQueryRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py deleted file mode 100644 index a57ab86c2b03f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py +++ /dev/null @@ -1,661 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._scheduled_query_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ScheduledQueryRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_04_16.aio.MonitorManagementClient`'s - :attr:`scheduled_query_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.LogSearchRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Creates or updates an log search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Creates or updates an log search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.LogSearchRuleResource, IO], - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Creates or updates an log search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - LogSearchRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LogSearchRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: - """Gets an Log Search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.LogSearchRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Update log search Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Update log search Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.LogSearchRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Update log search Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a LogSearchRuleResourcePatch - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LogSearchRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a Log Search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace - def list_by_subscription( - self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.LogSearchRuleResource"]: - """List the Log Search rules within a subscription group. - - :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.LogSearchRuleResource"]: - """List the Log Search rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py deleted file mode 100644 index 72a250bda7be6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py +++ /dev/null @@ -1,63 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import Action -from ._models_py3 import AlertingAction -from ._models_py3 import AzNsActionGroup -from ._models_py3 import Criteria -from ._models_py3 import Dimension -from ._models_py3 import ErrorContract -from ._models_py3 import ErrorResponse -from ._models_py3 import LogMetricTrigger -from ._models_py3 import LogSearchRuleResource -from ._models_py3 import LogSearchRuleResourceCollection -from ._models_py3 import LogSearchRuleResourcePatch -from ._models_py3 import LogToMetricAction -from ._models_py3 import Resource -from ._models_py3 import Schedule -from ._models_py3 import Source -from ._models_py3 import TriggerCondition - -from ._monitor_management_client_enums import AlertSeverity -from ._monitor_management_client_enums import ConditionalOperator -from ._monitor_management_client_enums import Enabled -from ._monitor_management_client_enums import MetricTriggerType -from ._monitor_management_client_enums import Operator -from ._monitor_management_client_enums import ProvisioningState -from ._monitor_management_client_enums import QueryType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Action", - "AlertingAction", - "AzNsActionGroup", - "Criteria", - "Dimension", - "ErrorContract", - "ErrorResponse", - "LogMetricTrigger", - "LogSearchRuleResource", - "LogSearchRuleResourceCollection", - "LogSearchRuleResourcePatch", - "LogToMetricAction", - "Resource", - "Schedule", - "Source", - "TriggerCondition", - "AlertSeverity", - "ConditionalOperator", - "Enabled", - "MetricTriggerType", - "Operator", - "ProvisioningState", - "QueryType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py deleted file mode 100644 index df113d7354f19..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py +++ /dev/null @@ -1,759 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Action(_serialization.Model): - """Action descriptor. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AlertingAction, LogToMetricAction - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. - Required. - :vartype odata_type: str - """ - - _validation = { - "odata_type": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - } - - _subtype_map = { - "odata_type": { - "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction": "AlertingAction", - "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction": "LogToMetricAction", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.odata_type: Optional[str] = None - - -class AlertingAction(Action): - """Specify action need to be taken when rule type is Alert. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. - Required. - :vartype odata_type: str - :ivar severity: Severity of the alert. Required. Known values are: "0", "1", "2", "3", and "4". - :vartype severity: str or ~azure.mgmt.monitor.v2018_04_16.models.AlertSeverity - :ivar azns_action: Azure action group reference. - :vartype azns_action: ~azure.mgmt.monitor.v2018_04_16.models.AzNsActionGroup - :ivar throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. - :vartype throttling_in_min: int - :ivar trigger: The trigger condition that results in the alert rule being. Required. - :vartype trigger: ~azure.mgmt.monitor.v2018_04_16.models.TriggerCondition - """ - - _validation = { - "odata_type": {"required": True}, - "severity": {"required": True}, - "trigger": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "severity": {"key": "severity", "type": "str"}, - "azns_action": {"key": "aznsAction", "type": "AzNsActionGroup"}, - "throttling_in_min": {"key": "throttlingInMin", "type": "int"}, - "trigger": {"key": "trigger", "type": "TriggerCondition"}, - } - - def __init__( - self, - *, - severity: Union[str, "_models.AlertSeverity"], - trigger: "_models.TriggerCondition", - azns_action: Optional["_models.AzNsActionGroup"] = None, - throttling_in_min: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword severity: Severity of the alert. Required. Known values are: "0", "1", "2", "3", and - "4". - :paramtype severity: str or ~azure.mgmt.monitor.v2018_04_16.models.AlertSeverity - :keyword azns_action: Azure action group reference. - :paramtype azns_action: ~azure.mgmt.monitor.v2018_04_16.models.AzNsActionGroup - :keyword throttling_in_min: time (in minutes) for which Alerts should be throttled or - suppressed. - :paramtype throttling_in_min: int - :keyword trigger: The trigger condition that results in the alert rule being. Required. - :paramtype trigger: ~azure.mgmt.monitor.v2018_04_16.models.TriggerCondition - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction" - self.severity = severity - self.azns_action = azns_action - self.throttling_in_min = throttling_in_min - self.trigger = trigger - - -class AzNsActionGroup(_serialization.Model): - """Azure action group. - - :ivar action_group: Azure Action Group reference. - :vartype action_group: list[str] - :ivar email_subject: Custom subject override for all email ids in Azure action group. - :vartype email_subject: str - :ivar custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action - group. - :vartype custom_webhook_payload: str - """ - - _attribute_map = { - "action_group": {"key": "actionGroup", "type": "[str]"}, - "email_subject": {"key": "emailSubject", "type": "str"}, - "custom_webhook_payload": {"key": "customWebhookPayload", "type": "str"}, - } - - def __init__( - self, - *, - action_group: Optional[List[str]] = None, - email_subject: Optional[str] = None, - custom_webhook_payload: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword action_group: Azure Action Group reference. - :paramtype action_group: list[str] - :keyword email_subject: Custom subject override for all email ids in Azure action group. - :paramtype email_subject: str - :keyword custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action - group. - :paramtype custom_webhook_payload: str - """ - super().__init__(**kwargs) - self.action_group = action_group - self.email_subject = email_subject - self.custom_webhook_payload = custom_webhook_payload - - -class Criteria(_serialization.Model): - """Specifies the criteria for converting log to metric. - - All required parameters must be populated in order to send to Azure. - - :ivar metric_name: Name of the metric. Required. - :vartype metric_name: str - :ivar dimensions: List of Dimensions for creating metric. - :vartype dimensions: list[~azure.mgmt.monitor.v2018_04_16.models.Dimension] - """ - - _validation = { - "metric_name": {"required": True}, - } - - _attribute_map = { - "metric_name": {"key": "metricName", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[Dimension]"}, - } - - def __init__( - self, *, metric_name: str, dimensions: Optional[List["_models.Dimension"]] = None, **kwargs: Any - ) -> None: - """ - :keyword metric_name: Name of the metric. Required. - :paramtype metric_name: str - :keyword dimensions: List of Dimensions for creating metric. - :paramtype dimensions: list[~azure.mgmt.monitor.v2018_04_16.models.Dimension] - """ - super().__init__(**kwargs) - self.metric_name = metric_name - self.dimensions = dimensions - - -class Dimension(_serialization.Model): - """Specifies the criteria for converting log to metric. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the dimension. Required. - :vartype name: str - :ivar operator: Operator for dimension values. Required. "Include" - :vartype operator: str or ~azure.mgmt.monitor.v2018_04_16.models.Operator - :ivar values: List of dimension values. Required. - :vartype values: list[str] - """ - - _validation = { - "name": {"required": True}, - "operator": {"required": True}, - "values": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - } - - def __init__( - self, *, name: str, operator: Union[str, "_models.Operator"], values: List[str], **kwargs: Any - ) -> None: - """ - :keyword name: Name of the dimension. Required. - :paramtype name: str - :keyword operator: Operator for dimension values. Required. "Include" - :paramtype operator: str or ~azure.mgmt.monitor.v2018_04_16.models.Operator - :keyword values: List of dimension values. Required. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.operator = operator - self.values = values - - -class ErrorContract(_serialization.Model): - """Describes the format of Error response. - - :ivar error: The error details. - :vartype error: ~azure.mgmt.monitor.v2018_04_16.models.ErrorResponse - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponse"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error details. - :paramtype error: ~azure.mgmt.monitor.v2018_04_16.models.ErrorResponse - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class LogMetricTrigger(_serialization.Model): - """A log metrics trigger descriptor. - - :ivar threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or - 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", - and "Equal". - :vartype threshold_operator: str or ~azure.mgmt.monitor.v2018_04_16.models.ConditionalOperator - :ivar threshold: The threshold of the metric trigger. - :vartype threshold: float - :ivar metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: - "Consecutive" and "Total". - :vartype metric_trigger_type: str or ~azure.mgmt.monitor.v2018_04_16.models.MetricTriggerType - :ivar metric_column: Evaluation of metric on a particular column. - :vartype metric_column: str - """ - - _attribute_map = { - "threshold_operator": {"key": "thresholdOperator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "metric_trigger_type": {"key": "metricTriggerType", "type": "str"}, - "metric_column": {"key": "metricColumn", "type": "str"}, - } - - def __init__( - self, - *, - threshold_operator: Union[str, "_models.ConditionalOperator"] = "GreaterThanOrEqual", - threshold: Optional[float] = None, - metric_trigger_type: Union[str, "_models.MetricTriggerType"] = "Consecutive", - metric_column: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or - 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", - and "Equal". - :paramtype threshold_operator: str or - ~azure.mgmt.monitor.v2018_04_16.models.ConditionalOperator - :keyword threshold: The threshold of the metric trigger. - :paramtype threshold: float - :keyword metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: - "Consecutive" and "Total". - :paramtype metric_trigger_type: str or ~azure.mgmt.monitor.v2018_04_16.models.MetricTriggerType - :keyword metric_column: Evaluation of metric on a particular column. - :paramtype metric_column: str - """ - super().__init__(**kwargs) - self.threshold_operator = threshold_operator - self.threshold = threshold - self.metric_trigger_type = metric_trigger_type - self.metric_column = metric_column - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :vartype kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "kind": {"readonly": True}, - "etag": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.kind = None - self.etag = None - - -class LogSearchRuleResource(Resource): # pylint: disable=too-many-instance-attributes - """The Log Search Rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :vartype kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :ivar created_with_api_version: The api-version used when creating this alert rule. - :vartype created_with_api_version: str - :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. - :vartype is_legacy_log_analytics_rule: bool - :ivar description: The description of the Log Search rule. - :vartype description: str - :ivar display_name: The display name of the alert rule. - :vartype display_name: str - :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved - or not. The default is false. - :vartype auto_mitigate: bool - :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be - true or false. Known values are: "true" and "false". - :vartype enabled: str or ~azure.mgmt.monitor.v2018_04_16.models.Enabled - :ivar last_updated_time: Last time the rule was updated in IS08601 format. - :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the scheduled query rule. Known values are: - "Succeeded", "Deploying", "Canceled", and "Failed". - :vartype provisioning_state: str or ~azure.mgmt.monitor.v2018_04_16.models.ProvisioningState - :ivar source: Data Source against which rule will Query Data. Required. - :vartype source: ~azure.mgmt.monitor.v2018_04_16.models.Source - :ivar schedule: Schedule (Frequency, Time Window) for rule. Required for action type - - AlertingAction. - :vartype schedule: ~azure.mgmt.monitor.v2018_04_16.models.Schedule - :ivar action: Action needs to be taken on rule execution. Required. - :vartype action: ~azure.mgmt.monitor.v2018_04_16.models.Action - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "kind": {"readonly": True}, - "etag": {"readonly": True}, - "created_with_api_version": {"readonly": True}, - "is_legacy_log_analytics_rule": {"readonly": True}, - "last_updated_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "source": {"required": True}, - "action": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, - "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, - "enabled": {"key": "properties.enabled", "type": "str"}, - "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "source": {"key": "properties.source", "type": "Source"}, - "schedule": {"key": "properties.schedule", "type": "Schedule"}, - "action": {"key": "properties.action", "type": "Action"}, - } - - def __init__( - self, - *, - location: str, - source: "_models.Source", - action: "_models.Action", - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - display_name: Optional[str] = None, - auto_mitigate: bool = False, - enabled: Optional[Union[str, "_models.Enabled"]] = None, - schedule: Optional["_models.Schedule"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of the Log Search rule. - :paramtype description: str - :keyword display_name: The display name of the alert rule. - :paramtype display_name: str - :keyword auto_mitigate: The flag that indicates whether the alert should be automatically - resolved or not. The default is false. - :paramtype auto_mitigate: bool - :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Known values are: "true" and "false". - :paramtype enabled: str or ~azure.mgmt.monitor.v2018_04_16.models.Enabled - :keyword source: Data Source against which rule will Query Data. Required. - :paramtype source: ~azure.mgmt.monitor.v2018_04_16.models.Source - :keyword schedule: Schedule (Frequency, Time Window) for rule. Required for action type - - AlertingAction. - :paramtype schedule: ~azure.mgmt.monitor.v2018_04_16.models.Schedule - :keyword action: Action needs to be taken on rule execution. Required. - :paramtype action: ~azure.mgmt.monitor.v2018_04_16.models.Action - """ - super().__init__(location=location, tags=tags, **kwargs) - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = description - self.display_name = display_name - self.auto_mitigate = auto_mitigate - self.enabled = enabled - self.last_updated_time = None - self.provisioning_state = None - self.source = source - self.schedule = schedule - self.action = action - - -class LogSearchRuleResourceCollection(_serialization.Model): - """Represents a collection of Log Search rule resources. - - :ivar value: The values for the Log Search Rule resources. - :vartype value: list[~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[LogSearchRuleResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.LogSearchRuleResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The values for the Log Search Rule resources. - :paramtype value: list[~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource] - """ - super().__init__(**kwargs) - self.value = value - - -class LogSearchRuleResourcePatch(_serialization.Model): - """The log search rule resource for patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be - true or false. Known values are: "true" and "false". - :vartype enabled: str or ~azure.mgmt.monitor.v2018_04_16.models.Enabled - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled: Optional[Union[str, "_models.Enabled"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Known values are: "true" and "false". - :paramtype enabled: str or ~azure.mgmt.monitor.v2018_04_16.models.Enabled - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class LogToMetricAction(Action): - """Specify action need to be taken when rule type is converting log to metric. - - All required parameters must be populated in order to send to Azure. - - :ivar odata_type: Specifies the action. Supported values - AlertingAction, LogToMetricAction. - Required. - :vartype odata_type: str - :ivar criteria: Criteria of Metric. Required. - :vartype criteria: list[~azure.mgmt.monitor.v2018_04_16.models.Criteria] - """ - - _validation = { - "odata_type": {"required": True}, - "criteria": {"required": True}, - } - - _attribute_map = { - "odata_type": {"key": "odata\\.type", "type": "str"}, - "criteria": {"key": "criteria", "type": "[Criteria]"}, - } - - def __init__(self, *, criteria: List["_models.Criteria"], **kwargs: Any) -> None: - """ - :keyword criteria: Criteria of Metric. Required. - :paramtype criteria: list[~azure.mgmt.monitor.v2018_04_16.models.Criteria] - """ - super().__init__(**kwargs) - self.odata_type: str = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction" - self.criteria = criteria - - -class Schedule(_serialization.Model): - """Defines how often to run the search and the time interval. - - All required parameters must be populated in order to send to Azure. - - :ivar frequency_in_minutes: frequency (in minutes) at which rule condition should be evaluated. - Required. - :vartype frequency_in_minutes: int - :ivar time_window_in_minutes: Time window for which data needs to be fetched for query (should - be greater than or equal to frequencyInMinutes). Required. - :vartype time_window_in_minutes: int - """ - - _validation = { - "frequency_in_minutes": {"required": True}, - "time_window_in_minutes": {"required": True}, - } - - _attribute_map = { - "frequency_in_minutes": {"key": "frequencyInMinutes", "type": "int"}, - "time_window_in_minutes": {"key": "timeWindowInMinutes", "type": "int"}, - } - - def __init__(self, *, frequency_in_minutes: int, time_window_in_minutes: int, **kwargs: Any) -> None: - """ - :keyword frequency_in_minutes: frequency (in minutes) at which rule condition should be - evaluated. Required. - :paramtype frequency_in_minutes: int - :keyword time_window_in_minutes: Time window for which data needs to be fetched for query - (should be greater than or equal to frequencyInMinutes). Required. - :paramtype time_window_in_minutes: int - """ - super().__init__(**kwargs) - self.frequency_in_minutes = frequency_in_minutes - self.time_window_in_minutes = time_window_in_minutes - - -class Source(_serialization.Model): - """Specifies the log search query. - - All required parameters must be populated in order to send to Azure. - - :ivar query: Log search query. Required for action type - AlertingAction. - :vartype query: str - :ivar authorized_resources: List of Resource referred into query. - :vartype authorized_resources: list[str] - :ivar data_source_id: The resource uri over which log search query is to be run. Required. - :vartype data_source_id: str - :ivar query_type: Set value to 'ResultCount' . "ResultCount" - :vartype query_type: str or ~azure.mgmt.monitor.v2018_04_16.models.QueryType - """ - - _validation = { - "data_source_id": {"required": True}, - } - - _attribute_map = { - "query": {"key": "query", "type": "str"}, - "authorized_resources": {"key": "authorizedResources", "type": "[str]"}, - "data_source_id": {"key": "dataSourceId", "type": "str"}, - "query_type": {"key": "queryType", "type": "str"}, - } - - def __init__( - self, - *, - data_source_id: str, - query: Optional[str] = None, - authorized_resources: Optional[List[str]] = None, - query_type: Optional[Union[str, "_models.QueryType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword query: Log search query. Required for action type - AlertingAction. - :paramtype query: str - :keyword authorized_resources: List of Resource referred into query. - :paramtype authorized_resources: list[str] - :keyword data_source_id: The resource uri over which log search query is to be run. Required. - :paramtype data_source_id: str - :keyword query_type: Set value to 'ResultCount' . "ResultCount" - :paramtype query_type: str or ~azure.mgmt.monitor.v2018_04_16.models.QueryType - """ - super().__init__(**kwargs) - self.query = query - self.authorized_resources = authorized_resources - self.data_source_id = data_source_id - self.query_type = query_type - - -class TriggerCondition(_serialization.Model): - """The condition that results in the Log Search rule. - - All required parameters must be populated in order to send to Azure. - - :ivar threshold_operator: Evaluation operation for rule - 'GreaterThan' or 'LessThan. Known - values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", and "Equal". - :vartype threshold_operator: str or ~azure.mgmt.monitor.v2018_04_16.models.ConditionalOperator - :ivar threshold: Result or count threshold based on which rule should be triggered. Required. - :vartype threshold: float - :ivar metric_trigger: Trigger condition for metric query rule. - :vartype metric_trigger: ~azure.mgmt.monitor.v2018_04_16.models.LogMetricTrigger - """ - - _validation = { - "threshold_operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "threshold_operator": {"key": "thresholdOperator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "metric_trigger": {"key": "metricTrigger", "type": "LogMetricTrigger"}, - } - - def __init__( - self, - *, - threshold_operator: Union[str, "_models.ConditionalOperator"] = "GreaterThanOrEqual", - threshold: float, - metric_trigger: Optional["_models.LogMetricTrigger"] = None, - **kwargs: Any - ) -> None: - """ - :keyword threshold_operator: Evaluation operation for rule - 'GreaterThan' or 'LessThan. Known - values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", and "Equal". - :paramtype threshold_operator: str or - ~azure.mgmt.monitor.v2018_04_16.models.ConditionalOperator - :keyword threshold: Result or count threshold based on which rule should be triggered. - Required. - :paramtype threshold: float - :keyword metric_trigger: Trigger condition for metric query rule. - :paramtype metric_trigger: ~azure.mgmt.monitor.v2018_04_16.models.LogMetricTrigger - """ - super().__init__(**kwargs) - self.threshold_operator = threshold_operator - self.threshold = threshold - self.metric_trigger = metric_trigger diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py deleted file mode 100644 index 6462be05d90ad..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Severity Level of Alert.""" - - ZERO = "0" - ONE = "1" - TWO = "2" - THREE = "3" - FOUR = "4" - - -class ConditionalOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Result Condition Evaluation criteria.""" - - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - GREATER_THAN = "GreaterThan" - LESS_THAN = "LessThan" - EQUAL = "Equal" - - -class Enabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The flag which indicates whether the Log Search rule is enabled. Value should be true or false.""" - - TRUE = "true" - FALSE = "false" - - -class MetricTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Metric Trigger Evaluation Type.""" - - CONSECUTIVE = "Consecutive" - TOTAL = "Total" - - -class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operator for dimension values.""" - - INCLUDE = "Include" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the scheduled query rule.""" - - SUCCEEDED = "Succeeded" - DEPLOYING = "Deploying" - CANCELED = "Canceled" - FAILED = "Failed" - - -class QueryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Set value to 'ResultAccount'.""" - - RESULT_COUNT = "ResultCount" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py deleted file mode 100644 index e010c281d4fc5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ScheduledQueryRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py deleted file mode 100644 index 6b70283f25a02..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py +++ /dev/null @@ -1,852 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request( - subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request( - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ScheduledQueryRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_04_16.MonitorManagementClient`'s - :attr:`scheduled_query_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.LogSearchRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Creates or updates an log search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Creates or updates an log search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.LogSearchRuleResource, IO], - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Creates or updates an log search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - LogSearchRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LogSearchRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: - """Gets an Log Search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.LogSearchRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Update log search Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Update log search Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.LogSearchRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.LogSearchRuleResource: - """Update log search Rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a LogSearchRuleResourcePatch - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LogSearchRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "LogSearchRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a Log Search rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace - def list_by_subscription( - self, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.LogSearchRuleResource"]: - """List the Log Search rules within a subscription group. - - :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.LogSearchRuleResource"]: - """List the Log Search rules within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_04_16.models.LogSearchRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) - cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py deleted file mode 100644 index 31454ff2ef96d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-06-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json deleted file mode 100644 index a48d09b87bd59..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2018-06-01-preview", - "total_api_version_list": ["2018-06-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "guest_diagnostics_settings_association": "GuestDiagnosticsSettingsAssociationOperations", - "guest_diagnostics_settings": "GuestDiagnosticsSettingsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py deleted file mode 100644 index 33794da101b23..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,99 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations - operations - :vartype guest_diagnostics_settings_association: - azure.mgmt.monitor.v2018_06_01_preview.operations.GuestDiagnosticsSettingsAssociationOperations - :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations - :vartype guest_diagnostics_settings: - azure.mgmt.monitor.v2018_06_01_preview.operations.GuestDiagnosticsSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py deleted file mode 100644 index 44fe163ef8695..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-06-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index c395f083fff56..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,99 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations - operations - :vartype guest_diagnostics_settings_association: - azure.mgmt.monitor.v2018_06_01_preview.aio.operations.GuestDiagnosticsSettingsAssociationOperations - :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations - :vartype guest_diagnostics_settings: - azure.mgmt.monitor.v2018_06_01_preview.aio.operations.GuestDiagnosticsSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py deleted file mode 100644 index 2f4965e07c4c7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._guest_diagnostics_settings_association_operations import GuestDiagnosticsSettingsAssociationOperations -from ._guest_diagnostics_settings_operations import GuestDiagnosticsSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GuestDiagnosticsSettingsAssociationOperations", - "GuestDiagnosticsSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py deleted file mode 100644 index 26aa8584c5dd7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py +++ /dev/null @@ -1,666 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._guest_diagnostics_settings_association_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GuestDiagnosticsSettingsAssociationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_06_01_preview.aio.MonitorManagementClient`'s - :attr:`guest_diagnostics_settings_association` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_uri: str, - association_name: str, - diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Creates or updates guest diagnostics settings association. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param diagnostic_settings_association: The diagnostic settings association to create or - update. Required. - :type diagnostic_settings_association: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_uri: str, - association_name: str, - diagnostic_settings_association: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Creates or updates guest diagnostics settings association. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param diagnostic_settings_association: The diagnostic settings association to create or - update. Required. - :type diagnostic_settings_association: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_uri: str, - association_name: str, - diagnostic_settings_association: Union[_models.GuestDiagnosticSettingsAssociationResource, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Creates or updates guest diagnostics settings association. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param diagnostic_settings_association: The diagnostic settings association to create or - update. Is either a GuestDiagnosticSettingsAssociationResource type or a IO type. Required. - :type diagnostic_settings_association: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(diagnostic_settings_association, (IO, bytes)): - _content = diagnostic_settings_association - else: - _json = self._serialize.body(diagnostic_settings_association, "GuestDiagnosticSettingsAssociationResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @distributed_trace_async - async def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Gets guest diagnostics association settings. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Delete guest diagnostics association settings. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @overload - async def update( - self, - resource_uri: str, - association_name: str, - parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use - the CreateOrUpdate method. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_uri: str, - association_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use - the CreateOrUpdate method. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_uri: str, - association_name: str, - parameters: Union[_models.GuestDiagnosticSettingsAssociationResourcePatch, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use - the CreateOrUpdate method. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param parameters: Parameters supplied to the operation. Is either a - GuestDiagnosticSettingsAssociationResourcePatch type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "GuestDiagnosticSettingsAssociationResourcePatch") - - request = build_update_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationResource"]: - """Get a list of all guest diagnostic settings association in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationResource"]: - """Get a list of all guest diagnostic settings association in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py deleted file mode 100644 index 8096714e84e2c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py +++ /dev/null @@ -1,659 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._guest_diagnostics_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GuestDiagnosticsSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_06_01_preview.aio.MonitorManagementClient`'s - :attr:`guest_diagnostics_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - diagnostic_settings: _models.GuestDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Creates or updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Required. - :type diagnostic_settings: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - diagnostic_settings: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Creates or updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Required. - :type diagnostic_settings: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - diagnostic_settings: Union[_models.GuestDiagnosticSettingsResource, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Creates or updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Is either a - GuestDiagnosticSettingsResource type or a IO type. Required. - :type diagnostic_settings: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(diagnostic_settings, (IO, bytes)): - _content = diagnostic_settings - else: - _json = self._serialize.body(diagnostic_settings, "GuestDiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Gets guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @overload - async def update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - parameters: _models.GuestDiagnosticSettingsPatchResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - parameters: Union[_models.GuestDiagnosticSettingsPatchResource, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Is either a GuestDiagnosticSettingsPatchResource - type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "GuestDiagnosticSettingsPatchResource") - - request = build_update_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any - ) -> None: - """Delete guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsResource"]: - """Get a list of all guest diagnostic settings in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GuestDiagnosticSettingsResource"]: - """Get a list of all guest diagnostic settings in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py deleted file mode 100644 index 4fa4abe4c38fc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import DataSource -from ._models_py3 import DataSourceConfiguration -from ._models_py3 import ErrorResponse -from ._models_py3 import EtwEventConfiguration -from ._models_py3 import EtwProviderConfiguration -from ._models_py3 import EventLogConfiguration -from ._models_py3 import GuestDiagnosticSettingsAssociationList -from ._models_py3 import GuestDiagnosticSettingsAssociationResource -from ._models_py3 import GuestDiagnosticSettingsAssociationResourcePatch -from ._models_py3 import GuestDiagnosticSettingsList -from ._models_py3 import GuestDiagnosticSettingsPatchResource -from ._models_py3 import GuestDiagnosticSettingsResource -from ._models_py3 import PerformanceCounterConfiguration -from ._models_py3 import Resource -from ._models_py3 import SinkConfiguration - -from ._monitor_management_client_enums import DataSourceKind -from ._monitor_management_client_enums import GuestDiagnosticSettingsOsType -from ._monitor_management_client_enums import SinkConfigurationKind -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataSource", - "DataSourceConfiguration", - "ErrorResponse", - "EtwEventConfiguration", - "EtwProviderConfiguration", - "EventLogConfiguration", - "GuestDiagnosticSettingsAssociationList", - "GuestDiagnosticSettingsAssociationResource", - "GuestDiagnosticSettingsAssociationResourcePatch", - "GuestDiagnosticSettingsList", - "GuestDiagnosticSettingsPatchResource", - "GuestDiagnosticSettingsResource", - "PerformanceCounterConfiguration", - "Resource", - "SinkConfiguration", - "DataSourceKind", - "GuestDiagnosticSettingsOsType", - "SinkConfigurationKind", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py deleted file mode 100644 index afe945cc42d10..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py +++ /dev/null @@ -1,658 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class DataSource(_serialization.Model): - """Data source object contains configuration to collect telemetry and one or more sinks to send - that telemetry data to. - - All required parameters must be populated in order to send to Azure. - - :ivar kind: Datasource kind. Required. Known values are: "PerformanceCounter", "ETWProviders", - and "WindowsEventLogs". - :vartype kind: str or ~azure.mgmt.monitor.v2018_06_01_preview.models.DataSourceKind - :ivar configuration: Required. - :vartype configuration: ~azure.mgmt.monitor.v2018_06_01_preview.models.DataSourceConfiguration - :ivar sinks: Required. - :vartype sinks: list[~azure.mgmt.monitor.v2018_06_01_preview.models.SinkConfiguration] - """ - - _validation = { - "kind": {"required": True}, - "configuration": {"required": True}, - "sinks": {"required": True}, - } - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - "configuration": {"key": "configuration", "type": "DataSourceConfiguration"}, - "sinks": {"key": "sinks", "type": "[SinkConfiguration]"}, - } - - def __init__( - self, - *, - kind: Union[str, "_models.DataSourceKind"], - configuration: "_models.DataSourceConfiguration", - sinks: List["_models.SinkConfiguration"], - **kwargs: Any - ) -> None: - """ - :keyword kind: Datasource kind. Required. Known values are: "PerformanceCounter", - "ETWProviders", and "WindowsEventLogs". - :paramtype kind: str or ~azure.mgmt.monitor.v2018_06_01_preview.models.DataSourceKind - :keyword configuration: Required. - :paramtype configuration: - ~azure.mgmt.monitor.v2018_06_01_preview.models.DataSourceConfiguration - :keyword sinks: Required. - :paramtype sinks: list[~azure.mgmt.monitor.v2018_06_01_preview.models.SinkConfiguration] - """ - super().__init__(**kwargs) - self.kind = kind - self.configuration = configuration - self.sinks = sinks - - -class DataSourceConfiguration(_serialization.Model): - """DataSourceConfiguration. - - :ivar providers: ETW providers configuration. - :vartype providers: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.EtwProviderConfiguration] - :ivar perf_counters: Performance counter configuration. - :vartype perf_counters: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.PerformanceCounterConfiguration] - :ivar event_logs: Windows event logs configuration. - :vartype event_logs: list[~azure.mgmt.monitor.v2018_06_01_preview.models.EventLogConfiguration] - """ - - _attribute_map = { - "providers": {"key": "providers", "type": "[EtwProviderConfiguration]"}, - "perf_counters": {"key": "perfCounters", "type": "[PerformanceCounterConfiguration]"}, - "event_logs": {"key": "eventLogs", "type": "[EventLogConfiguration]"}, - } - - def __init__( - self, - *, - providers: Optional[List["_models.EtwProviderConfiguration"]] = None, - perf_counters: Optional[List["_models.PerformanceCounterConfiguration"]] = None, - event_logs: Optional[List["_models.EventLogConfiguration"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword providers: ETW providers configuration. - :paramtype providers: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.EtwProviderConfiguration] - :keyword perf_counters: Performance counter configuration. - :paramtype perf_counters: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.PerformanceCounterConfiguration] - :keyword event_logs: Windows event logs configuration. - :paramtype event_logs: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.EventLogConfiguration] - """ - super().__init__(**kwargs) - self.providers = providers - self.perf_counters = perf_counters - self.event_logs = event_logs - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class EtwEventConfiguration(_serialization.Model): - """EtwEventConfiguration. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Required. - :vartype name: str - :ivar id: Required. - :vartype id: int - :ivar filter: - :vartype filter: str - """ - - _validation = { - "name": {"required": True}, - "id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "id": {"key": "id", "type": "int"}, - "filter": {"key": "filter", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - id: int, # pylint: disable=redefined-builtin - filter: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword name: Required. - :paramtype name: str - :keyword id: Required. - :paramtype id: int - :keyword filter: - :paramtype filter: str - """ - super().__init__(**kwargs) - self.name = name - self.id = id - self.filter = filter - - -class EtwProviderConfiguration(_serialization.Model): - """EtwProviderConfiguration. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Required. - :vartype id: str - :ivar events: Required. - :vartype events: list[~azure.mgmt.monitor.v2018_06_01_preview.models.EtwEventConfiguration] - """ - - _validation = { - "id": {"required": True}, - "events": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "events": {"key": "events", "type": "[EtwEventConfiguration]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - events: List["_models.EtwEventConfiguration"], - **kwargs: Any - ) -> None: - """ - :keyword id: Required. - :paramtype id: str - :keyword events: Required. - :paramtype events: list[~azure.mgmt.monitor.v2018_06_01_preview.models.EtwEventConfiguration] - """ - super().__init__(**kwargs) - self.id = id - self.events = events - - -class EventLogConfiguration(_serialization.Model): - """EventLogConfiguration. - - All required parameters must be populated in order to send to Azure. - - :ivar log_name: Required. - :vartype log_name: str - :ivar filter: - :vartype filter: str - """ - - _validation = { - "log_name": {"required": True}, - } - - _attribute_map = { - "log_name": {"key": "logName", "type": "str"}, - "filter": {"key": "filter", "type": "str"}, - } - - def __init__( - self, *, log_name: str, filter: Optional[str] = None, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword log_name: Required. - :paramtype log_name: str - :keyword filter: - :paramtype filter: str - """ - super().__init__(**kwargs) - self.log_name = log_name - self.filter = filter - - -class GuestDiagnosticSettingsAssociationList(_serialization.Model): - """A list of guest diagnostic settings association. - - :ivar value: The list of guest diagnostic settings association. - :vartype value: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GuestDiagnosticSettingsAssociationResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.GuestDiagnosticSettingsAssociationResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of guest diagnostic settings association. - :paramtype value: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class GuestDiagnosticSettingsAssociationResource(Resource): - """Virtual machine guest diagnostic settings resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. Required. - :vartype guest_diagnostic_settings_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "guest_diagnostic_settings_name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "guest_diagnostic_settings_name": {"key": "properties.guestDiagnosticSettingsName", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - guest_diagnostic_settings_name: str, - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. Required. - :paramtype guest_diagnostic_settings_name: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.guest_diagnostic_settings_name = guest_diagnostic_settings_name - - -class GuestDiagnosticSettingsAssociationResourcePatch(_serialization.Model): - """Guest diagnostic setting resource for patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. - :vartype guest_diagnostic_settings_name: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "guest_diagnostic_settings_name": {"key": "properties.guestDiagnosticSettingsName", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - guest_diagnostic_settings_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. - :paramtype guest_diagnostic_settings_name: str - """ - super().__init__(**kwargs) - self.tags = tags - self.guest_diagnostic_settings_name = guest_diagnostic_settings_name - - -class GuestDiagnosticSettingsList(_serialization.Model): - """A list of guest diagnostic settings. - - :ivar value: The list of guest diagnostic settings. - :vartype value: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GuestDiagnosticSettingsResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.GuestDiagnosticSettingsResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of guest diagnostic settings. - :paramtype value: - list[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class GuestDiagnosticSettingsPatchResource(_serialization.Model): - """An diagnostic settings object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar os_type: Operating system type for the configuration. Known values are: "Windows" and - "Linux". - :vartype os_type: str or - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :ivar data_sources: the array of data source object which are configured to collect and send - data. - :vartype data_sources: list[~azure.mgmt.monitor.v2018_06_01_preview.models.DataSource] - :ivar proxy_setting: - :vartype proxy_setting: str - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "data_sources": {"key": "properties.dataSources", "type": "[DataSource]"}, - "proxy_setting": {"key": "properties.proxySetting", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, - data_sources: Optional[List["_models.DataSource"]] = None, - proxy_setting: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword os_type: Operating system type for the configuration. Known values are: "Windows" and - "Linux". - :paramtype os_type: str or - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :keyword data_sources: the array of data source object which are configured to collect and send - data. - :paramtype data_sources: list[~azure.mgmt.monitor.v2018_06_01_preview.models.DataSource] - :keyword proxy_setting: - :paramtype proxy_setting: str - """ - super().__init__(**kwargs) - self.tags = tags - self.os_type = os_type - self.data_sources = data_sources - self.proxy_setting = proxy_setting - - -class GuestDiagnosticSettingsResource(Resource): - """Virtual machine guest diagnostics settings resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar os_type: Operating system type for the configuration. Known values are: "Windows" and - "Linux". - :vartype os_type: str or - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :ivar data_sources: the array of data source object which are configured to collect and send - data. - :vartype data_sources: list[~azure.mgmt.monitor.v2018_06_01_preview.models.DataSource] - :ivar proxy_setting: - :vartype proxy_setting: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "data_sources": {"key": "properties.dataSources", "type": "[DataSource]"}, - "proxy_setting": {"key": "properties.proxySetting", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, - data_sources: Optional[List["_models.DataSource"]] = None, - proxy_setting: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword os_type: Operating system type for the configuration. Known values are: "Windows" and - "Linux". - :paramtype os_type: str or - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :keyword data_sources: the array of data source object which are configured to collect and send - data. - :paramtype data_sources: list[~azure.mgmt.monitor.v2018_06_01_preview.models.DataSource] - :keyword proxy_setting: - :paramtype proxy_setting: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.os_type = os_type - self.data_sources = data_sources - self.proxy_setting = proxy_setting - - -class PerformanceCounterConfiguration(_serialization.Model): - """PerformanceCounterConfiguration. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Required. - :vartype name: str - :ivar sampling_period: Required. - :vartype sampling_period: str - :ivar instance: - :vartype instance: str - """ - - _validation = { - "name": {"required": True}, - "sampling_period": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "sampling_period": {"key": "samplingPeriod", "type": "str"}, - "instance": {"key": "instance", "type": "str"}, - } - - def __init__(self, *, name: str, sampling_period: str, instance: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: Required. - :paramtype name: str - :keyword sampling_period: Required. - :paramtype sampling_period: str - :keyword instance: - :paramtype instance: str - """ - super().__init__(**kwargs) - self.name = name - self.sampling_period = sampling_period - self.instance = instance - - -class SinkConfiguration(_serialization.Model): - """SinkConfiguration. - - All required parameters must be populated in order to send to Azure. - - :ivar kind: Required. Known values are: "EventHub", "ApplicationInsights", and "LogAnalytics". - :vartype kind: str or ~azure.mgmt.monitor.v2018_06_01_preview.models.SinkConfigurationKind - """ - - _validation = { - "kind": {"required": True}, - } - - _attribute_map = { - "kind": {"key": "kind", "type": "str"}, - } - - def __init__(self, *, kind: Union[str, "_models.SinkConfigurationKind"], **kwargs: Any) -> None: - """ - :keyword kind: Required. Known values are: "EventHub", "ApplicationInsights", and - "LogAnalytics". - :paramtype kind: str or ~azure.mgmt.monitor.v2018_06_01_preview.models.SinkConfigurationKind - """ - super().__init__(**kwargs) - self.kind = kind diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 37e9e206ca1bd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class DataSourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Datasource kind.""" - - PERFORMANCE_COUNTER = "PerformanceCounter" - ETW_PROVIDERS = "ETWProviders" - WINDOWS_EVENT_LOGS = "WindowsEventLogs" - - -class GuestDiagnosticSettingsOsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operating system type for the configuration.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class SinkConfigurationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SinkConfigurationKind.""" - - EVENT_HUB = "EventHub" - APPLICATION_INSIGHTS = "ApplicationInsights" - LOG_ANALYTICS = "LogAnalytics" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py deleted file mode 100644 index 2f4965e07c4c7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._guest_diagnostics_settings_association_operations import GuestDiagnosticsSettingsAssociationOperations -from ._guest_diagnostics_settings_operations import GuestDiagnosticsSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "GuestDiagnosticsSettingsAssociationOperations", - "GuestDiagnosticsSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py deleted file mode 100644 index ca480b1c92cd4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py +++ /dev/null @@ -1,836 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class GuestDiagnosticsSettingsAssociationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_06_01_preview.MonitorManagementClient`'s - :attr:`guest_diagnostics_settings_association` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_uri: str, - association_name: str, - diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Creates or updates guest diagnostics settings association. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param diagnostic_settings_association: The diagnostic settings association to create or - update. Required. - :type diagnostic_settings_association: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_uri: str, - association_name: str, - diagnostic_settings_association: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Creates or updates guest diagnostics settings association. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param diagnostic_settings_association: The diagnostic settings association to create or - update. Required. - :type diagnostic_settings_association: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_uri: str, - association_name: str, - diagnostic_settings_association: Union[_models.GuestDiagnosticSettingsAssociationResource, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Creates or updates guest diagnostics settings association. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param diagnostic_settings_association: The diagnostic settings association to create or - update. Is either a GuestDiagnosticSettingsAssociationResource type or a IO type. Required. - :type diagnostic_settings_association: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(diagnostic_settings_association, (IO, bytes)): - _content = diagnostic_settings_association - else: - _json = self._serialize.body(diagnostic_settings_association, "GuestDiagnosticSettingsAssociationResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @distributed_trace - def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Gets guest diagnostics association settings. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Delete guest diagnostics association settings. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @overload - def update( - self, - resource_uri: str, - association_name: str, - parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use - the CreateOrUpdate method. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_uri: str, - association_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use - the CreateOrUpdate method. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_uri: str, - association_name: str, - parameters: Union[_models.GuestDiagnosticSettingsAssociationResourcePatch, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsAssociationResource: - """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use - the CreateOrUpdate method. - - :param resource_uri: The fully qualified ID of the resource, including the resource name and - resource type. Required. - :type resource_uri: str - :param association_name: The name of the diagnostic settings association. Required. - :type association_name: str - :param parameters: Parameters supplied to the operation. Is either a - GuestDiagnosticSettingsAssociationResourcePatch type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsAssociationResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "GuestDiagnosticSettingsAssociationResourcePatch") - - request = build_update_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsAssociationResource"]: - """Get a list of all guest diagnostic settings association in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GuestDiagnosticSettingsAssociationResource"]: - """Get a list of all guest diagnostic settings association in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsAssociationResource or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py deleted file mode 100644 index c27ec6eebc81f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py +++ /dev/null @@ -1,848 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, diagnostic_settings_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class GuestDiagnosticsSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_06_01_preview.MonitorManagementClient`'s - :attr:`guest_diagnostics_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - diagnostic_settings: _models.GuestDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Creates or updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Required. - :type diagnostic_settings: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - diagnostic_settings: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Creates or updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Required. - :type diagnostic_settings: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - diagnostic_settings: Union[_models.GuestDiagnosticSettingsResource, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Creates or updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Is either a - GuestDiagnosticSettingsResource type or a IO type. Required. - :type diagnostic_settings: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(diagnostic_settings, (IO, bytes)): - _content = diagnostic_settings - else: - _json = self._serialize.body(diagnostic_settings, "GuestDiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @distributed_trace - def get( - self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Gets guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @overload - def update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - parameters: _models.GuestDiagnosticSettingsPatchResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - diagnostic_settings_name: str, - parameters: Union[_models.GuestDiagnosticSettingsPatchResource, IO], - **kwargs: Any - ) -> _models.GuestDiagnosticSettingsResource: - """Updates guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Is either a GuestDiagnosticSettingsPatchResource - type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "GuestDiagnosticSettingsPatchResource") - - request = build_update_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any - ) -> None: - """Delete guest diagnostics settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param diagnostic_settings_name: The name of the diagnostic setting. Required. - :type diagnostic_settings_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - diagnostic_settings_name=diagnostic_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsResource"]: - """Get a list of all guest diagnostic settings in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GuestDiagnosticSettingsResource"]: - """Get a list of all guest diagnostic settings in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestDiagnosticSettingsResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) - cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py deleted file mode 100644 index 20fa7a9824739..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json deleted file mode 100644 index 729ae3d52af89..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2018-09-01", - "total_api_version_list": ["2018-09-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations", - "baselines": "BaselinesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py deleted file mode 100644 index b3a942c1f3a39..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, BaselinesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2018_09_01.operations.ActionGroupsOperations - :ivar baselines: BaselinesOperations operations - :vartype baselines: azure.mgmt.monitor.v2018_09_01.operations.BaselinesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py deleted file mode 100644 index a71fe19692e20..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py deleted file mode 100644 index 8046bc9f7c147..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, BaselinesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2018_09_01.aio.operations.ActionGroupsOperations - :ivar baselines: BaselinesOperations operations - :vartype baselines: azure.mgmt.monitor.v2018_09_01.aio.operations.BaselinesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py deleted file mode 100644 index ea540c4b7b93a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._baselines_operations import BaselinesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "BaselinesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index ab1e0bae3655d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,792 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_09_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2018_09_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2018_09_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py deleted file mode 100644 index 5b11f1cba4f63..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py +++ /dev/null @@ -1,193 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._baselines_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class BaselinesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_09_01.aio.MonitorManagementClient`'s - :attr:`baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, - resource_uri: str, - metricnames: Optional[str] = None, - metricnamespace: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SingleMetricBaseline"]: - """**Lists the metric baseline values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnames: 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'**. Default value is None. - :type metricnames: str - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is - None. - :type sensitivities: str - :param filter: 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' "**. Default value is None. - :type filter: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Known values are: "Data" and "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2018_09_01.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SingleMetricBaseline or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2018_09_01.models.SingleMetricBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py deleted file mode 100644 index b29f7c4a325e4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ArmRoleReceiver -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import BaselineMetadata -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import ItsmReceiver -from ._models_py3 import LogicAppReceiver -from ._models_py3 import MetricBaselinesResponse -from ._models_py3 import MetricSingleDimension -from ._models_py3 import Resource -from ._models_py3 import SingleBaseline -from ._models_py3 import SingleMetricBaseline -from ._models_py3 import SmsReceiver -from ._models_py3 import TimeSeriesBaseline -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import BaselineSensitivity -from ._monitor_management_client_enums import ReceiverStatus -from ._monitor_management_client_enums import ResultType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ArmRoleReceiver", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "BaselineMetadata", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "ItsmReceiver", - "LogicAppReceiver", - "MetricBaselinesResponse", - "MetricSingleDimension", - "Resource", - "SingleBaseline", - "SingleMetricBaseline", - "SmsReceiver", - "TimeSeriesBaseline", - "VoiceReceiver", - "WebhookReceiver", - "BaselineSensitivity", - "ReceiverStatus", - "ResultType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py deleted file mode 100644 index 2b3dbebf8638e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py +++ /dev/null @@ -1,1096 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class Resource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(Resource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2018_09_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2018_09_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2018_09_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.ArmRoleReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2018_09_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2018_09_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2018_09_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2018_09_01.models.ArmRoleReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - - -class ArmRoleReceiver(_serialization.Model): - """An arm role receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the arm role receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar role_id: The arm role id. Required. - :vartype role_id: str - """ - - _validation = { - "name": {"required": True}, - "role_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "role_id": {"key": "roleId", "type": "str"}, - } - - def __init__(self, *, name: str, role_id: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the arm role receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword role_id: The arm role id. Required. - :paramtype role_id: str - """ - super().__init__(**kwargs) - self.name = name - self.role_id = role_id - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - } - - def __init__( - self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - - -class BaselineMetadata(_serialization.Model): - """Represents a baseline metadata value. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the baseline metadata. Required. - :vartype name: str - :ivar value: Value of the baseline metadata. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: Name of the baseline metadata. Required. - :paramtype name: str - :keyword value: Value of the baseline metadata. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2018_09_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - } - - def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - - -class MetricBaselinesResponse(_serialization.Model): - """A list of metric baselines. - - All required parameters must be populated in order to send to Azure. - - :ivar timespan: 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. Required. - :vartype timespan: str - :ivar interval: 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. Required. - :vartype interval: ~datetime.timedelta - :ivar namespace: The namespace of the metrics been queried. - :vartype namespace: str - :ivar value: The baseline for each time series that was queried. - :vartype value: list[~azure.mgmt.monitor.v2018_09_01.models.SingleMetricBaseline] - """ - - _validation = { - "timespan": {"required": True}, - "interval": {"required": True}, - } - - _attribute_map = { - "timespan": {"key": "timespan", "type": "str"}, - "interval": {"key": "interval", "type": "duration"}, - "namespace": {"key": "namespace", "type": "str"}, - "value": {"key": "value", "type": "[SingleMetricBaseline]"}, - } - - def __init__( - self, - *, - timespan: str, - interval: datetime.timedelta, - namespace: Optional[str] = None, - value: Optional[List["_models.SingleMetricBaseline"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword timespan: 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. Required. - :paramtype timespan: str - :keyword interval: 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. Required. - :paramtype interval: ~datetime.timedelta - :keyword namespace: The namespace of the metrics been queried. - :paramtype namespace: str - :keyword value: The baseline for each time series that was queried. - :paramtype value: list[~azure.mgmt.monitor.v2018_09_01.models.SingleMetricBaseline] - """ - super().__init__(**kwargs) - self.timespan = timespan - self.interval = interval - self.namespace = namespace - self.value = value - - -class MetricSingleDimension(_serialization.Model): - """The metric dimension name and value. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the dimension. Required. - :vartype name: str - :ivar value: Value of the dimension. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: Name of the dimension. Required. - :paramtype name: str - :keyword value: Value of the dimension. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class SingleBaseline(_serialization.Model): - """The baseline values for a single sensitivity value. - - All required parameters must be populated in order to send to Azure. - - :ivar sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", - "Medium", and "High". - :vartype sensitivity: str or ~azure.mgmt.monitor.v2018_09_01.models.BaselineSensitivity - :ivar low_thresholds: The low thresholds of the baseline. Required. - :vartype low_thresholds: list[float] - :ivar high_thresholds: The high thresholds of the baseline. Required. - :vartype high_thresholds: list[float] - """ - - _validation = { - "sensitivity": {"required": True}, - "low_thresholds": {"required": True}, - "high_thresholds": {"required": True}, - } - - _attribute_map = { - "sensitivity": {"key": "sensitivity", "type": "str"}, - "low_thresholds": {"key": "lowThresholds", "type": "[float]"}, - "high_thresholds": {"key": "highThresholds", "type": "[float]"}, - } - - def __init__( - self, - *, - sensitivity: Union[str, "_models.BaselineSensitivity"], - low_thresholds: List[float], - high_thresholds: List[float], - **kwargs: Any - ) -> None: - """ - :keyword sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", - "Medium", and "High". - :paramtype sensitivity: str or ~azure.mgmt.monitor.v2018_09_01.models.BaselineSensitivity - :keyword low_thresholds: The low thresholds of the baseline. Required. - :paramtype low_thresholds: list[float] - :keyword high_thresholds: The high thresholds of the baseline. Required. - :paramtype high_thresholds: list[float] - """ - super().__init__(**kwargs) - self.sensitivity = sensitivity - self.low_thresholds = low_thresholds - self.high_thresholds = high_thresholds - - -class SingleMetricBaseline(_serialization.Model): - """The baseline results of a single metric. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The metric baseline Id. Required. - :vartype id: str - :ivar type: The resource type of the metric baseline resource. Required. - :vartype type: str - :ivar metric_name: The name of the metric for which the baselines were retrieved. Required. - :vartype metric_name: str - :ivar baselines: The baseline for each time series that was queried. Required. - :vartype baselines: list[~azure.mgmt.monitor.v2018_09_01.models.TimeSeriesBaseline] - """ - - _validation = { - "id": {"required": True}, - "type": {"required": True}, - "metric_name": {"required": True}, - "baselines": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "metric_name": {"key": "metricName", "type": "str"}, - "baselines": {"key": "baselines", "type": "[TimeSeriesBaseline]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - type: str, - metric_name: str, - baselines: List["_models.TimeSeriesBaseline"], - **kwargs: Any - ) -> None: - """ - :keyword id: The metric baseline Id. Required. - :paramtype id: str - :keyword type: The resource type of the metric baseline resource. Required. - :paramtype type: str - :keyword metric_name: The name of the metric for which the baselines were retrieved. Required. - :paramtype metric_name: str - :keyword baselines: The baseline for each time series that was queried. Required. - :paramtype baselines: list[~azure.mgmt.monitor.v2018_09_01.models.TimeSeriesBaseline] - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.metric_name = metric_name - self.baselines = baselines - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2018_09_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class TimeSeriesBaseline(_serialization.Model): - """The baseline values for a single time series. - - All required parameters must be populated in order to send to Azure. - - :ivar aggregation: The aggregation type of the metric. Required. - :vartype aggregation: str - :ivar dimensions: The dimensions of this time series. - :vartype dimensions: list[~azure.mgmt.monitor.v2018_09_01.models.MetricSingleDimension] - :ivar timestamps: The list of timestamps of the baselines. Required. - :vartype timestamps: list[~datetime.datetime] - :ivar data: The baseline values for each sensitivity. Required. - :vartype data: list[~azure.mgmt.monitor.v2018_09_01.models.SingleBaseline] - :ivar metadata_values: The baseline metadata values. - :vartype metadata_values: list[~azure.mgmt.monitor.v2018_09_01.models.BaselineMetadata] - """ - - _validation = { - "aggregation": {"required": True}, - "timestamps": {"required": True}, - "data": {"required": True}, - } - - _attribute_map = { - "aggregation": {"key": "aggregation", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[MetricSingleDimension]"}, - "timestamps": {"key": "timestamps", "type": "[iso-8601]"}, - "data": {"key": "data", "type": "[SingleBaseline]"}, - "metadata_values": {"key": "metadataValues", "type": "[BaselineMetadata]"}, - } - - def __init__( - self, - *, - aggregation: str, - timestamps: List[datetime.datetime], - data: List["_models.SingleBaseline"], - dimensions: Optional[List["_models.MetricSingleDimension"]] = None, - metadata_values: Optional[List["_models.BaselineMetadata"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword aggregation: The aggregation type of the metric. Required. - :paramtype aggregation: str - :keyword dimensions: The dimensions of this time series. - :paramtype dimensions: list[~azure.mgmt.monitor.v2018_09_01.models.MetricSingleDimension] - :keyword timestamps: The list of timestamps of the baselines. Required. - :paramtype timestamps: list[~datetime.datetime] - :keyword data: The baseline values for each sensitivity. Required. - :paramtype data: list[~azure.mgmt.monitor.v2018_09_01.models.SingleBaseline] - :keyword metadata_values: The baseline metadata values. - :paramtype metadata_values: list[~azure.mgmt.monitor.v2018_09_01.models.BaselineMetadata] - """ - super().__init__(**kwargs) - self.aggregation = aggregation - self.dimensions = dimensions - self.timestamps = timestamps - self.data = data - self.metadata_values = metadata_values - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - } - - def __init__(self, *, name: str, service_uri: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py deleted file mode 100644 index bf08d44864b25..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class BaselineSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the sensitivity of the baseline.""" - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ResultType.""" - - DATA = "Data" - METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py deleted file mode 100644 index ea540c4b7b93a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._baselines_operations import BaselinesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "BaselinesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py deleted file mode 100644 index 30b66925f7efb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,1014 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_09_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2018_09_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2018_09_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py deleted file mode 100644 index ab54bcbbc1eac..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py +++ /dev/null @@ -1,248 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_uri: str, - *, - metricnames: Optional[str] = None, - metricnamespace: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricBaselines") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if metricnames is not None: - _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - if timespan is not None: - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - if aggregation is not None: - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - if sensitivities is not None: - _params["sensitivities"] = _SERIALIZER.query("sensitivities", sensitivities, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if result_type is not None: - _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class BaselinesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_09_01.MonitorManagementClient`'s - :attr:`baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, - resource_uri: str, - metricnames: Optional[str] = None, - metricnamespace: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any - ) -> Iterable["_models.SingleMetricBaseline"]: - """**Lists the metric baseline values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnames: 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'**. Default value is None. - :type metricnames: str - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is - None. - :type sensitivities: str - :param filter: 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' "**. Default value is None. - :type filter: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Known values are: "Data" and "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2018_09_01.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SingleMetricBaseline or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2018_09_01.models.SingleMetricBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py deleted file mode 100644 index 14b2024459683..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-11-27-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json deleted file mode 100644 index 5c87c22399675..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2018-11-27-preview", - "total_api_version_list": ["2018-11-27-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "vm_insights": "VMInsightsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py deleted file mode 100644 index 88d2d3d6ad3b1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import VMInsightsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar vm_insights: VMInsightsOperations operations - :vartype vm_insights: azure.mgmt.monitor.v2018_11_27_preview.operations.VMInsightsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py deleted file mode 100644 index a36e7edf06027..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-11-27-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py deleted file mode 100644 index 1b4d87006e7f6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import VMInsightsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar vm_insights: VMInsightsOperations operations - :vartype vm_insights: - azure.mgmt.monitor.v2018_11_27_preview.aio.operations.VMInsightsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py deleted file mode 100644 index d1c0fc736fe24..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._vm_insights_operations import VMInsightsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "VMInsightsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py deleted file mode 100644 index 76e316d50cb4e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py +++ /dev/null @@ -1,110 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._vm_insights_operations import build_get_onboarding_status_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class VMInsightsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_11_27_preview.aio.MonitorManagementClient`'s - :attr:`vm_insights` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMInsightsOnboardingStatus: - """Retrieves the VM Insights onboarding status for the specified resource or resource scope. - - :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or - scope, whose status to retrieve. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VMInsightsOnboardingStatus or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_11_27_preview.models.VMInsightsOnboardingStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) - cls: ClsType[_models.VMInsightsOnboardingStatus] = kwargs.pop("cls", None) - - request = build_get_onboarding_status_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.get_onboarding_status.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VMInsightsOnboardingStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_onboarding_status.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py deleted file mode 100644 index 1e469b6512149..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import DataContainer -from ._models_py3 import Error -from ._models_py3 import ProxyResource -from ._models_py3 import ResponseWithError -from ._models_py3 import VMInsightsOnboardingStatus -from ._models_py3 import WorkspaceInfo - -from ._monitor_management_client_enums import DataStatus -from ._monitor_management_client_enums import OnboardingStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataContainer", - "Error", - "ProxyResource", - "ResponseWithError", - "VMInsightsOnboardingStatus", - "WorkspaceInfo", - "DataStatus", - "OnboardingStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py deleted file mode 100644 index e3eac8d03fea3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py +++ /dev/null @@ -1,250 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class DataContainer(_serialization.Model): - """Information about a container with data for a given resource. - - All required parameters must be populated in order to send to Azure. - - :ivar workspace: Log Analytics workspace information. Required. - :vartype workspace: ~azure.mgmt.monitor.v2018_11_27_preview.models.WorkspaceInfo - """ - - _validation = { - "workspace": {"required": True}, - } - - _attribute_map = { - "workspace": {"key": "workspace", "type": "WorkspaceInfo"}, - } - - def __init__(self, *, workspace: "_models.WorkspaceInfo", **kwargs: Any) -> None: - """ - :keyword workspace: Log Analytics workspace information. Required. - :paramtype workspace: ~azure.mgmt.monitor.v2018_11_27_preview.models.WorkspaceInfo - """ - super().__init__(**kwargs) - self.workspace = workspace - - -class Error(_serialization.Model): - """Error details. - - All required parameters must be populated in order to send to Azure. - - :ivar code: Error code identifying the specific error. Required. - :vartype code: str - :ivar message: Error message in the caller's locale. - :vartype message: str - """ - - _validation = { - "code": {"required": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: str, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code identifying the specific error. Required. - :paramtype code: str - :keyword message: Error message in the caller's locale. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ProxyResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ResponseWithError(_serialization.Model): - """An error response from the API. - - All required parameters must be populated in order to send to Azure. - - :ivar error: Error information. Required. - :vartype error: ~azure.mgmt.monitor.v2018_11_27_preview.models.Error - """ - - _validation = { - "error": {"required": True}, - } - - _attribute_map = { - "error": {"key": "error", "type": "Error"}, - } - - def __init__(self, *, error: "_models.Error", **kwargs: Any) -> None: - """ - :keyword error: Error information. Required. - :paramtype error: ~azure.mgmt.monitor.v2018_11_27_preview.models.Error - """ - super().__init__(**kwargs) - self.error = error - - -class VMInsightsOnboardingStatus(ProxyResource): - """VM Insights onboarding status for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar resource_id: Azure Resource Manager identifier of the resource whose onboarding status is - being represented. - :vartype resource_id: str - :ivar onboarding_status: The onboarding status for the resource. Note that, a higher level - scope, e.g., resource group or subscription, is considered onboarded if at least one resource - under it is onboarded. Known values are: "onboarded", "notOnboarded", and "unknown". - :vartype onboarding_status: str or - ~azure.mgmt.monitor.v2018_11_27_preview.models.OnboardingStatus - :ivar data_status: The status of VM Insights data from the resource. When reported as - ``present`` the data array will contain information about the data containers to which data for - the specified resource is being routed. Known values are: "present" and "notPresent". - :vartype data_status: str or ~azure.mgmt.monitor.v2018_11_27_preview.models.DataStatus - :ivar data: Containers that currently store VM Insights data for the specified resource. - :vartype data: list[~azure.mgmt.monitor.v2018_11_27_preview.models.DataContainer] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "resource_id": {"key": "properties.resourceId", "type": "str"}, - "onboarding_status": {"key": "properties.onboardingStatus", "type": "str"}, - "data_status": {"key": "properties.dataStatus", "type": "str"}, - "data": {"key": "properties.data", "type": "[DataContainer]"}, - } - - def __init__( - self, - *, - resource_id: Optional[str] = None, - onboarding_status: Optional[Union[str, "_models.OnboardingStatus"]] = None, - data_status: Optional[Union[str, "_models.DataStatus"]] = None, - data: Optional[List["_models.DataContainer"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_id: Azure Resource Manager identifier of the resource whose onboarding status - is being represented. - :paramtype resource_id: str - :keyword onboarding_status: The onboarding status for the resource. Note that, a higher level - scope, e.g., resource group or subscription, is considered onboarded if at least one resource - under it is onboarded. Known values are: "onboarded", "notOnboarded", and "unknown". - :paramtype onboarding_status: str or - ~azure.mgmt.monitor.v2018_11_27_preview.models.OnboardingStatus - :keyword data_status: The status of VM Insights data from the resource. When reported as - ``present`` the data array will contain information about the data containers to which data for - the specified resource is being routed. Known values are: "present" and "notPresent". - :paramtype data_status: str or ~azure.mgmt.monitor.v2018_11_27_preview.models.DataStatus - :keyword data: Containers that currently store VM Insights data for the specified resource. - :paramtype data: list[~azure.mgmt.monitor.v2018_11_27_preview.models.DataContainer] - """ - super().__init__(**kwargs) - self.resource_id = resource_id - self.onboarding_status = onboarding_status - self.data_status = data_status - self.data = data - - -class WorkspaceInfo(_serialization.Model): - """Information about a Log Analytics Workspace. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure Resource Manager identifier of the Log Analytics Workspace. Required. - :vartype id: str - :ivar location: Location of the Log Analytics workspace. Required. - :vartype location: str - :ivar customer_id: Log Analytics workspace identifier. Required. - :vartype customer_id: str - """ - - _validation = { - "id": {"required": True}, - "location": {"required": True}, - "customer_id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "customer_id": {"key": "properties.customerId", "type": "str"}, - } - - def __init__( - self, *, id: str, location: str, customer_id: str, **kwargs: Any # pylint: disable=redefined-builtin - ) -> None: - """ - :keyword id: Azure Resource Manager identifier of the Log Analytics Workspace. Required. - :paramtype id: str - :keyword location: Location of the Log Analytics workspace. Required. - :paramtype location: str - :keyword customer_id: Log Analytics workspace identifier. Required. - :paramtype customer_id: str - """ - super().__init__(**kwargs) - self.id = id - self.location = location - self.customer_id = customer_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index b1ee153b301c3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,30 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class DataStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of VM Insights data from the resource. When reported as ``present`` the data array - will contain information about the data containers to which data for the specified resource is - being routed. - """ - - PRESENT = "present" - NOT_PRESENT = "notPresent" - - -class OnboardingStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The onboarding status for the resource. Note that, a higher level scope, e.g., resource group - or subscription, is considered onboarded if at least one resource under it is onboarded. - """ - - ONBOARDED = "onboarded" - NOT_ONBOARDED = "notOnboarded" - UNKNOWN = "unknown" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py deleted file mode 100644 index d1c0fc736fe24..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._vm_insights_operations import VMInsightsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "VMInsightsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py deleted file mode 100644 index acf14093a9bb0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py +++ /dev/null @@ -1,139 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_onboarding_status_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" - ) - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class VMInsightsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2018_11_27_preview.MonitorManagementClient`'s - :attr:`vm_insights` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMInsightsOnboardingStatus: - """Retrieves the VM Insights onboarding status for the specified resource or resource scope. - - :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or - scope, whose status to retrieve. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VMInsightsOnboardingStatus or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2018_11_27_preview.models.VMInsightsOnboardingStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) - cls: ClsType[_models.VMInsightsOnboardingStatus] = kwargs.pop("cls", None) - - request = build_get_onboarding_status_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.get_onboarding_status.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("VMInsightsOnboardingStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_onboarding_status.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py deleted file mode 100644 index 0e809d339236f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json deleted file mode 100644 index 59e413fdad82e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2019-03-01", - "total_api_version_list": ["2019-03-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations", - "baselines": "BaselinesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py deleted file mode 100644 index f2e87fc4aa8fe..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, BaselinesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2019_03_01.operations.ActionGroupsOperations - :ivar baselines: BaselinesOperations operations - :vartype baselines: azure.mgmt.monitor.v2019_03_01.operations.BaselinesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py deleted file mode 100644 index 62614c9a05515..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-03-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py deleted file mode 100644 index 362ffeb005680..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, BaselinesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2019_03_01.aio.operations.ActionGroupsOperations - :ivar baselines: BaselinesOperations operations - :vartype baselines: azure.mgmt.monitor.v2019_03_01.aio.operations.BaselinesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py deleted file mode 100644 index ea540c4b7b93a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._baselines_operations import BaselinesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "BaselinesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index 6ae5cced39754..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,792 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_03_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2019_03_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2019_03_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py deleted file mode 100644 index abda0768b7b39..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py +++ /dev/null @@ -1,193 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._baselines_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class BaselinesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_03_01.aio.MonitorManagementClient`'s - :attr:`baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, - resource_uri: str, - metricnames: Optional[str] = None, - metricnamespace: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SingleMetricBaseline"]: - """**Lists the metric baseline values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnames: 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'**. Default value is None. - :type metricnames: str - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is - None. - :type sensitivities: str - :param filter: 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' "**. Default value is None. - :type filter: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Known values are: "Data" and "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2019_03_01.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SingleMetricBaseline or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_03_01.models.SingleMetricBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py deleted file mode 100644 index a5d67150b91c9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ArmRoleReceiver -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import AzureResource -from ._models_py3 import BaselineMetadata -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import ItsmReceiver -from ._models_py3 import LogicAppReceiver -from ._models_py3 import MetricBaselinesResponse -from ._models_py3 import MetricSingleDimension -from ._models_py3 import SingleBaseline -from ._models_py3 import SingleMetricBaseline -from ._models_py3 import SmsReceiver -from ._models_py3 import TimeSeriesBaseline -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import BaselineSensitivity -from ._monitor_management_client_enums import ReceiverStatus -from ._monitor_management_client_enums import ResultType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ArmRoleReceiver", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "AzureResource", - "BaselineMetadata", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "ItsmReceiver", - "LogicAppReceiver", - "MetricBaselinesResponse", - "MetricSingleDimension", - "SingleBaseline", - "SingleMetricBaseline", - "SmsReceiver", - "TimeSeriesBaseline", - "VoiceReceiver", - "WebhookReceiver", - "BaselineSensitivity", - "ReceiverStatus", - "ResultType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py deleted file mode 100644 index 79e3bcc35e066..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py +++ /dev/null @@ -1,1132 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class AzureResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2019_03_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2019_03_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2019_03_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.ArmRoleReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2019_03_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2019_03_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2019_03_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2019_03_01.models.ArmRoleReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - - -class ArmRoleReceiver(_serialization.Model): - """An arm role receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the arm role receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar role_id: The arm role id. Required. - :vartype role_id: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "role_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "role_id": {"key": "roleId", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the arm role receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword role_id: The arm role id. Required. - :paramtype role_id: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.role_id = role_id - self.use_common_alert_schema = use_common_alert_schema - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - self.use_common_alert_schema = use_common_alert_schema - - -class BaselineMetadata(_serialization.Model): - """Represents a baseline metadata value. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the baseline metadata. Required. - :vartype name: str - :ivar value: Value of the baseline metadata. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: Name of the baseline metadata. Required. - :paramtype name: str - :keyword value: Value of the baseline metadata. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2019_03_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.use_common_alert_schema = use_common_alert_schema - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - self.use_common_alert_schema = use_common_alert_schema - - -class MetricBaselinesResponse(_serialization.Model): - """A list of metric baselines. - - :ivar value: The list of metric baselines. - :vartype value: list[~azure.mgmt.monitor.v2019_03_01.models.SingleMetricBaseline] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[SingleMetricBaseline]"}, - } - - def __init__(self, *, value: Optional[List["_models.SingleMetricBaseline"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of metric baselines. - :paramtype value: list[~azure.mgmt.monitor.v2019_03_01.models.SingleMetricBaseline] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricSingleDimension(_serialization.Model): - """The metric dimension name and value. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the dimension. Required. - :vartype name: str - :ivar value: Value of the dimension. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: Name of the dimension. Required. - :paramtype name: str - :keyword value: Value of the dimension. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class SingleBaseline(_serialization.Model): - """The baseline values for a single sensitivity value. - - All required parameters must be populated in order to send to Azure. - - :ivar sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", - "Medium", and "High". - :vartype sensitivity: str or ~azure.mgmt.monitor.v2019_03_01.models.BaselineSensitivity - :ivar low_thresholds: The low thresholds of the baseline. Required. - :vartype low_thresholds: list[float] - :ivar high_thresholds: The high thresholds of the baseline. Required. - :vartype high_thresholds: list[float] - """ - - _validation = { - "sensitivity": {"required": True}, - "low_thresholds": {"required": True}, - "high_thresholds": {"required": True}, - } - - _attribute_map = { - "sensitivity": {"key": "sensitivity", "type": "str"}, - "low_thresholds": {"key": "lowThresholds", "type": "[float]"}, - "high_thresholds": {"key": "highThresholds", "type": "[float]"}, - } - - def __init__( - self, - *, - sensitivity: Union[str, "_models.BaselineSensitivity"], - low_thresholds: List[float], - high_thresholds: List[float], - **kwargs: Any - ) -> None: - """ - :keyword sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", - "Medium", and "High". - :paramtype sensitivity: str or ~azure.mgmt.monitor.v2019_03_01.models.BaselineSensitivity - :keyword low_thresholds: The low thresholds of the baseline. Required. - :paramtype low_thresholds: list[float] - :keyword high_thresholds: The high thresholds of the baseline. Required. - :paramtype high_thresholds: list[float] - """ - super().__init__(**kwargs) - self.sensitivity = sensitivity - self.low_thresholds = low_thresholds - self.high_thresholds = high_thresholds - - -class SingleMetricBaseline(_serialization.Model): - """The baseline results of a single metric. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The metric baseline Id. Required. - :vartype id: str - :ivar type: The resource type of the metric baseline resource. Required. - :vartype type: str - :ivar name: The name of the metric for which the baselines were retrieved. Required. - :vartype name: str - :ivar timespan: 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. Required. - :vartype timespan: str - :ivar interval: 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. Required. - :vartype interval: ~datetime.timedelta - :ivar namespace: The namespace of the metrics been queried. - :vartype namespace: str - :ivar baselines: The baseline for each time series that was queried. Required. - :vartype baselines: list[~azure.mgmt.monitor.v2019_03_01.models.TimeSeriesBaseline] - """ - - _validation = { - "id": {"required": True}, - "type": {"required": True}, - "name": {"required": True}, - "timespan": {"required": True}, - "interval": {"required": True}, - "baselines": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "timespan": {"key": "properties.timespan", "type": "str"}, - "interval": {"key": "properties.interval", "type": "duration"}, - "namespace": {"key": "properties.namespace", "type": "str"}, - "baselines": {"key": "properties.baselines", "type": "[TimeSeriesBaseline]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - type: str, - name: str, - timespan: str, - interval: datetime.timedelta, - baselines: List["_models.TimeSeriesBaseline"], - namespace: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The metric baseline Id. Required. - :paramtype id: str - :keyword type: The resource type of the metric baseline resource. Required. - :paramtype type: str - :keyword name: The name of the metric for which the baselines were retrieved. Required. - :paramtype name: str - :keyword timespan: 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. Required. - :paramtype timespan: str - :keyword interval: 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. Required. - :paramtype interval: ~datetime.timedelta - :keyword namespace: The namespace of the metrics been queried. - :paramtype namespace: str - :keyword baselines: The baseline for each time series that was queried. Required. - :paramtype baselines: list[~azure.mgmt.monitor.v2019_03_01.models.TimeSeriesBaseline] - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.name = name - self.timespan = timespan - self.interval = interval - self.namespace = namespace - self.baselines = baselines - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2019_03_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class TimeSeriesBaseline(_serialization.Model): - """The baseline values for a single time series. - - All required parameters must be populated in order to send to Azure. - - :ivar aggregation: The aggregation type of the metric. Required. - :vartype aggregation: str - :ivar dimensions: The dimensions of this time series. - :vartype dimensions: list[~azure.mgmt.monitor.v2019_03_01.models.MetricSingleDimension] - :ivar timestamps: The list of timestamps of the baselines. Required. - :vartype timestamps: list[~datetime.datetime] - :ivar data: The baseline values for each sensitivity. Required. - :vartype data: list[~azure.mgmt.monitor.v2019_03_01.models.SingleBaseline] - :ivar metadata_values: The baseline metadata values. - :vartype metadata_values: list[~azure.mgmt.monitor.v2019_03_01.models.BaselineMetadata] - """ - - _validation = { - "aggregation": {"required": True}, - "timestamps": {"required": True}, - "data": {"required": True}, - } - - _attribute_map = { - "aggregation": {"key": "aggregation", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[MetricSingleDimension]"}, - "timestamps": {"key": "timestamps", "type": "[iso-8601]"}, - "data": {"key": "data", "type": "[SingleBaseline]"}, - "metadata_values": {"key": "metadataValues", "type": "[BaselineMetadata]"}, - } - - def __init__( - self, - *, - aggregation: str, - timestamps: List[datetime.datetime], - data: List["_models.SingleBaseline"], - dimensions: Optional[List["_models.MetricSingleDimension"]] = None, - metadata_values: Optional[List["_models.BaselineMetadata"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword aggregation: The aggregation type of the metric. Required. - :paramtype aggregation: str - :keyword dimensions: The dimensions of this time series. - :paramtype dimensions: list[~azure.mgmt.monitor.v2019_03_01.models.MetricSingleDimension] - :keyword timestamps: The list of timestamps of the baselines. Required. - :paramtype timestamps: list[~datetime.datetime] - :keyword data: The baseline values for each sensitivity. Required. - :paramtype data: list[~azure.mgmt.monitor.v2019_03_01.models.SingleBaseline] - :keyword metadata_values: The baseline metadata values. - :paramtype metadata_values: list[~azure.mgmt.monitor.v2019_03_01.models.BaselineMetadata] - """ - super().__init__(**kwargs) - self.aggregation = aggregation - self.dimensions = dimensions - self.timestamps = timestamps - self.data = data - self.metadata_values = metadata_values - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__(self, *, name: str, service_uri: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py deleted file mode 100644 index bf08d44864b25..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class BaselineSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the sensitivity of the baseline.""" - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ResultType.""" - - DATA = "Data" - METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py deleted file mode 100644 index ea540c4b7b93a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._baselines_operations import BaselinesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "BaselinesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py deleted file mode 100644 index 1d0be57f94be3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,1014 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_03_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_03_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2019_03_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2019_03_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py deleted file mode 100644 index 126e2ba6d2b01..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py +++ /dev/null @@ -1,248 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - resource_uri: str, - *, - metricnames: Optional[str] = None, - metricnamespace: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricBaselines") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if metricnames is not None: - _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - if timespan is not None: - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - if aggregation is not None: - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - if sensitivities is not None: - _params["sensitivities"] = _SERIALIZER.query("sensitivities", sensitivities, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if result_type is not None: - _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class BaselinesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_03_01.MonitorManagementClient`'s - :attr:`baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list( - self, - resource_uri: str, - metricnames: Optional[str] = None, - metricnamespace: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - **kwargs: Any - ) -> Iterable["_models.SingleMetricBaseline"]: - """**Lists the metric baseline values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnames: 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'**. Default value is None. - :type metricnames: str - :param metricnamespace: Metric namespace to query metric definitions for. Default value is - None. - :type metricnamespace: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is - None. - :type sensitivities: str - :param filter: 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' "**. Default value is None. - :type filter: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. Known values are: "Data" and "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2019_03_01.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SingleMetricBaseline or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_03_01.models.SingleMetricBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) - cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnames=metricnames, - metricnamespace=metricnamespace, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - filter=filter, - result_type=result_type, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py deleted file mode 100644 index dc401fa09a71f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json deleted file mode 100644 index 662a3ad580f22..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2019-06-01", - "total_api_version_list": ["2019-06-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py deleted file mode 100644 index 5b40269f3683c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2019_06_01.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py deleted file mode 100644 index 44ead2faf77d3..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py deleted file mode 100644 index 9b4f78b0ba819..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2019_06_01.aio.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index b3f157b37ce1a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,792 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_06_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2019_06_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2019_06_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py deleted file mode 100644 index 2755a8fd3548c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ArmRoleReceiver -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import AzureResource -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import ItsmReceiver -from ._models_py3 import LogicAppReceiver -from ._models_py3 import SmsReceiver -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ArmRoleReceiver", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "AzureResource", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "ItsmReceiver", - "LogicAppReceiver", - "SmsReceiver", - "VoiceReceiver", - "WebhookReceiver", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py deleted file mode 100644 index 2f5b964326a29..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py +++ /dev/null @@ -1,884 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class AzureResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2019_06_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2019_06_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2019_06_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.ArmRoleReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2019_06_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2019_06_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2019_06_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2019_06_01.models.ArmRoleReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - - -class ArmRoleReceiver(_serialization.Model): - """An arm role receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the arm role receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar role_id: The arm role id. Required. - :vartype role_id: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "role_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "role_id": {"key": "roleId", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the arm role receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword role_id: The arm role id. Required. - :paramtype role_id: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.role_id = role_id - self.use_common_alert_schema = use_common_alert_schema - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - self.use_common_alert_schema = use_common_alert_schema - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2019_06_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.use_common_alert_schema = use_common_alert_schema - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - self.use_common_alert_schema = use_common_alert_schema - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2019_06_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar use_aad_auth: Indicates whether or not use AAD authentication. - :vartype use_aad_auth: bool - :ivar object_id: Indicates the webhook app object Id for aad auth. - :vartype object_id: str - :ivar identifier_uri: Indicates the identifier uri for aad auth. - :vartype identifier_uri: str - :ivar tenant_id: Indicates the tenant id for aad auth. - :vartype tenant_id: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, - "object_id": {"key": "objectId", "type": "str"}, - "identifier_uri": {"key": "identifierUri", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - service_uri: str, - use_common_alert_schema: bool = False, - use_aad_auth: bool = False, - object_id: Optional[str] = None, - identifier_uri: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword use_aad_auth: Indicates whether or not use AAD authentication. - :paramtype use_aad_auth: bool - :keyword object_id: Indicates the webhook app object Id for aad auth. - :paramtype object_id: str - :keyword identifier_uri: Indicates the identifier uri for aad auth. - :paramtype identifier_uri: str - :keyword tenant_id: Indicates the tenant id for aad auth. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - self.use_aad_auth = use_aad_auth - self.object_id = object_id - self.identifier_uri = identifier_uri - self.tenant_id = tenant_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 2502d854d1869..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py deleted file mode 100644 index 0fdbc97491bb1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,1014 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_06_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2019_06_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2019_06_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 409]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py deleted file mode 100644 index 7b27cbdf9da5c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-10-17-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json deleted file mode 100644 index cd2778252553b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2019-10-17-preview", - "total_api_version_list": ["2019-10-17-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "private_link_scopes": "PrivateLinkScopesOperations", - "private_link_scope_operation_status": "PrivateLinkScopeOperationStatusOperations", - "private_link_resources": "PrivateLinkResourcesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "private_link_scoped_resources": "PrivateLinkScopedResourcesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py deleted file mode 100644 index 93b667d3b1e34..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - PrivateLinkScopeOperationStatusOperations, - PrivateLinkScopedResourcesOperations, - PrivateLinkScopesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: - azure.mgmt.monitor.v2019_10_17.operations.PrivateLinkScopesOperations - :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations - :vartype private_link_scope_operation_status: - azure.mgmt.monitor.v2019_10_17.operations.PrivateLinkScopeOperationStatusOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.monitor.v2019_10_17.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.monitor.v2019_10_17.operations.PrivateEndpointConnectionsOperations - :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations - :vartype private_link_scoped_resources: - azure.mgmt.monitor.v2019_10_17.operations.PrivateLinkScopedResourcesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.private_link_scopes = PrivateLinkScopesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py deleted file mode 100644 index fd98a3ea043da..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-10-17-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py deleted file mode 100644 index 22862094ca058..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - PrivateLinkScopeOperationStatusOperations, - PrivateLinkScopedResourcesOperations, - PrivateLinkScopesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: - azure.mgmt.monitor.v2019_10_17.aio.operations.PrivateLinkScopesOperations - :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations - :vartype private_link_scope_operation_status: - azure.mgmt.monitor.v2019_10_17.aio.operations.PrivateLinkScopeOperationStatusOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.monitor.v2019_10_17.aio.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.monitor.v2019_10_17.aio.operations.PrivateEndpointConnectionsOperations - :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations - :vartype private_link_scoped_resources: - azure.mgmt.monitor.v2019_10_17.aio.operations.PrivateLinkScopedResourcesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.private_link_scopes = PrivateLinkScopesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py deleted file mode 100644 index 1f7c00746a8dc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._private_link_scopes_operations import PrivateLinkScopesOperations -from ._private_link_scope_operation_status_operations import PrivateLinkScopeOperationStatusOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PrivateLinkScopesOperations", - "PrivateLinkScopeOperationStatusOperations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "PrivateLinkScopedResourcesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 4256bcd0373b9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,575 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_private_link_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.aio.MonitorManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index a36b124e51668..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,213 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.aio.MonitorManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResource"]: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_10_17.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py deleted file mode 100644 index 670fdc09b4188..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py +++ /dev/null @@ -1,114 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_scope_operation_status_operations import build_get_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkScopeOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.aio.MonitorManagementClient`'s - :attr:`private_link_scope_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: - """Get the status of an azure asynchronous operation associated with a private link scope - operation. - - :param async_operation_id: The operation Id. Required. - :type async_operation_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - async_operation_id=async_operation_id, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py deleted file mode 100644 index 66552cbfd75fa..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py +++ /dev/null @@ -1,575 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_scoped_resources_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_private_link_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkScopedResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.aio.MonitorManagementClient`'s - :attr:`private_link_scoped_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: - """Gets a scoped resource in a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopedResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.ScopedResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> Optional[_models.ScopedResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ScopedResource]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScopedResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: _models.ScopedResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.ScopedResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Is either a ScopedResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.ScopedResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopedResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ScopedResource"]: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py deleted file mode 100644 index 019d14d72b96d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py +++ /dev/null @@ -1,711 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_scopes_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_tags_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkScopesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.aio.MonitorManagementClient`'s - :attr:`private_link_scopes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Returns a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a - IO type. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_private_link_scope_payload, (IO, bytes)): - _content = azure_monitor_private_link_scope_payload - else: - _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - async def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: _models.TagsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2019_10_17.models.TagsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: Union[_models.TagsResource, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a TagsResource type or a IO type. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2019_10_17.models.TagsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_link_scope_tags, (IO, bytes)): - _content = private_link_scope_tags - else: - _json = self._serialize.body(private_link_scope_tags, "TagsResource") - - request = build_update_tags_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update_tags.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py deleted file mode 100644 index 5947e1f13a83e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py +++ /dev/null @@ -1,50 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AzureMonitorPrivateLinkScope -from ._models_py3 import AzureMonitorPrivateLinkScopeListResult -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorResponse -from ._models_py3 import ErrorResponseCommon -from ._models_py3 import OperationStatus -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateEndpointProperty -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkScopesResource -from ._models_py3 import PrivateLinkServiceConnectionStateProperty -from ._models_py3 import ProxyResource -from ._models_py3 import ScopedResource -from ._models_py3 import ScopedResourceListResult -from ._models_py3 import TagsResource -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureMonitorPrivateLinkScope", - "AzureMonitorPrivateLinkScopeListResult", - "ErrorAdditionalInfo", - "ErrorResponse", - "ErrorResponseCommon", - "OperationStatus", - "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", - "PrivateEndpointProperty", - "PrivateLinkResource", - "PrivateLinkResourceListResult", - "PrivateLinkScopesResource", - "PrivateLinkServiceConnectionStateProperty", - "ProxyResource", - "ScopedResource", - "ScopedResourceListResult", - "TagsResource", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py deleted file mode 100644 index 22eabfbd961c4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py +++ /dev/null @@ -1,656 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class PrivateLinkScopesResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): - """An Azure Monitor PrivateLinkScope definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar provisioning_state: 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. - :vartype provisioning_state: str - :ivar private_endpoint_connections: List of private endpoint connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.provisioning_state = None - self.private_endpoint_connections = None - - -class AzureMonitorPrivateLinkScopeListResult(_serialization.Model): - """Describes the list of Azure Monitor PrivateLinkScope resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: List of Azure Monitor PrivateLinkScope definitions. Required. - :vartype value: list[~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope] - :ivar next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if - too many PrivateLinkScopes where returned in the result set. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AzureMonitorPrivateLinkScope]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AzureMonitorPrivateLinkScope"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of Azure Monitor PrivateLinkScope definitions. Required. - :paramtype value: list[~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope] - :keyword next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions - if too many PrivateLinkScopes where returned in the result set. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ErrorResponseCommon(ErrorResponse): - """The resource management error response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2019_10_17.models.ErrorResponseCommon] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.monitor.v2019_10_17.models.ErrorAdditionalInfo] - """ - - _validation = { - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorResponseCommon]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(code=code, message=message, **kwargs) - self.details = None - self.additional_info = None - - -class OperationStatus(_serialization.Model): - """The status of operation. - - :ivar id: The operation Id. - :vartype id: str - :ivar name: The operation name. - :vartype name: str - :ivar start_time: Start time of the job in standard ISO8601 format. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the job in standard ISO8601 format. - :vartype end_time: ~datetime.datetime - :ivar status: The status of the operation. - :vartype status: str - :ivar error: The error detail of the operation if any. - :vartype error: ~azure.mgmt.monitor.v2019_10_17.models.ErrorResponseCommon - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "status": {"key": "status", "type": "str"}, - "error": {"key": "error", "type": "ErrorResponseCommon"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - status: Optional[str] = None, - error: Optional["_models.ErrorResponseCommon"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The operation Id. - :paramtype id: str - :keyword name: The operation name. - :paramtype name: str - :keyword start_time: Start time of the job in standard ISO8601 format. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time of the job in standard ISO8601 format. - :paramtype end_time: ~datetime.datetime - :keyword status: The status of the operation. - :paramtype status: str - :keyword error: The error detail of the operation if any. - :paramtype error: ~azure.mgmt.monitor.v2019_10_17.models.ErrorResponseCommon - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.start_time = start_time - self.end_time = end_time - self.status = status - self.error = error - - -class ProxyResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class PrivateEndpointConnection(ProxyResource): - """A private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar private_endpoint: Private endpoint which the connection belongs to. - :vartype private_endpoint: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointProperty - :ivar private_link_service_connection_state: Connection state of the private endpoint - connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.monitor.v2019_10_17.models.PrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the private endpoint connection. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionStateProperty", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: Private endpoint which the connection belongs to. - :paramtype private_endpoint: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointProperty - :keyword private_link_service_connection_state: Connection state of the private endpoint - connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.monitor.v2019_10_17.models.PrivateLinkServiceConnectionStateProperty - """ - super().__init__(**kwargs) - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """A list of private endpoint connections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpointProperty(_serialization.Model): - """Private endpoint which the connection belongs to. - - :ivar id: Resource id of the private endpoint. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource id of the private endpoint. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class PrivateLinkResource(ProxyResource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.group_id = None - self.required_members = None - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.monitor.v2019_10_17.models.PrivateLinkResource] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateLinkServiceConnectionStateProperty(_serialization.Model): - """State of the private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar status: The private link service connection status. Required. - :vartype status: str - :ivar description: The private link service connection description. Required. - :vartype description: str - :ivar actions_required: The actions required for private link service connection. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - "actions_required": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__(self, *, status: str, description: str, **kwargs: Any) -> None: - """ - :keyword status: The private link service connection status. Required. - :paramtype status: str - :keyword description: The private link service connection description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = None - - -class ScopedResource(ProxyResource): - """A private link scoped resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar linked_resource_id: The resource id of the scoped Azure monitor resource. - :vartype linked_resource_id: str - :ivar provisioning_state: State of the private endpoint connection. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "linked_resource_id": {"key": "properties.linkedResourceId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, *, linked_resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword linked_resource_id: The resource id of the scoped Azure monitor resource. - :paramtype linked_resource_id: str - """ - super().__init__(**kwargs) - self.linked_resource_id = linked_resource_id - self.provisioning_state = None - - -class ScopedResourceListResult(_serialization.Model): - """A list of scoped resources in a private link scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ScopedResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class TagsResource(_serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on a - PrivateLinkScope instance. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py deleted file mode 100644 index 1f7c00746a8dc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._private_link_scopes_operations import PrivateLinkScopesOperations -from ._private_link_scope_operation_status_operations import PrivateLinkScopeOperationStatusOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PrivateLinkScopesOperations", - "PrivateLinkScopeOperationStatusOperations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "PrivateLinkScopedResourcesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 12f8057c1e29c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,722 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_private_link_scope_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.MonitorManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py deleted file mode 100644 index 9c81b625304ad..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,282 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_private_link_scope_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, scope_name: str, group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "groupName": _SERIALIZER.url("group_name", group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.MonitorManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateLinkResource"]: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_10_17.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources" - } - - @distributed_trace - def get( - self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py deleted file mode 100644 index 55cc021cddeb6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py +++ /dev/null @@ -1,150 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - async_operation_id: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkScopeOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.MonitorManagementClient`'s - :attr:`private_link_scope_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: - """Get the status of an azure asynchronous operation associated with a private link scope - operation. - - :param async_operation_id: The operation Id. Required. - :type async_operation_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - async_operation_id=async_operation_id, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py deleted file mode 100644 index d7fbfff8d25df..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py +++ /dev/null @@ -1,698 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_private_link_scope_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkScopedResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.MonitorManagementClient`'s - :attr:`private_link_scoped_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: - """Gets a scoped resource in a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopedResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.ScopedResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> Optional[_models.ScopedResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ScopedResource]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScopedResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: _models.ScopedResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.ScopedResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> LROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Is either a ScopedResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2019_10_17.models.ScopedResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopedResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace - def begin_delete(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> Iterable["_models.ScopedResource"]: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py deleted file mode 100644 index 9a177d0cc9ca9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py +++ /dev/null @@ -1,886 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_get_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_tags_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkScopesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_10_17.MonitorManagementClient`'s - :attr:`private_link_scopes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace - def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace - def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _models.AzureMonitorPrivateLinkScope: - """Returns a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a - IO type. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_private_link_scope_payload, (IO, bytes)): - _content = azure_monitor_private_link_scope_payload - else: - _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: _models.TagsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2019_10_17.models.TagsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: Union[_models.TagsResource, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a TagsResource type or a IO type. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2019_10_17.models.TagsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_10_17.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_link_scope_tags, (IO, bytes)): - _content = private_link_scope_tags - else: - _json = self._serialize.body(private_link_scope_tags, "TagsResource") - - request = build_update_tags_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update_tags.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py deleted file mode 100644 index 73d4713452337..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-11-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json deleted file mode 100644 index aa8b405524f51..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2019-11-01-preview", - "total_api_version_list": ["2019-11-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", - "data_collection_rules": "DataCollectionRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py deleted file mode 100644 index 6f276c3202226..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2019_11_01_preview.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2019_11_01_preview.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py deleted file mode 100644 index ba7d63ed5b53a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-11-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 78f9c865e6df1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2019_11_01_preview.aio.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2019_11_01_preview.aio.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py deleted file mode 100644 index cb4e5ea6755ea..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index 45961e6de505b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,535 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rule_associations_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_request, - build_list_by_rule_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_11_01_preview.aio.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace_async - async def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py deleted file mode 100644 index ccb81f47d0794..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rules_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_11_01_preview.aio.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py deleted file mode 100644 index 20e7277139ffc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py +++ /dev/null @@ -1,85 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AzureMonitorMetricsDestination -from ._models_py3 import DataCollectionRule -from ._models_py3 import DataCollectionRuleAssociation -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties -from ._models_py3 import DataCollectionRuleDataSources -from ._models_py3 import DataCollectionRuleDestinations -from ._models_py3 import DataCollectionRuleResource -from ._models_py3 import DataCollectionRuleResourceListResult -from ._models_py3 import DataCollectionRuleResourceProperties -from ._models_py3 import DataFlow -from ._models_py3 import DataSourcesSpec -from ._models_py3 import DestinationsSpec -from ._models_py3 import DestinationsSpecAzureMonitorMetrics -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import ExtensionDataSource -from ._models_py3 import LogAnalyticsDestination -from ._models_py3 import PerfCounterDataSource -from ._models_py3 import ResourceForUpdate -from ._models_py3 import SyslogDataSource -from ._models_py3 import WindowsEventLogDataSource - -from ._monitor_management_client_enums import KnownDataCollectionRuleAssociationProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleResourceKind -from ._monitor_management_client_enums import KnownDataFlowStreams -from ._monitor_management_client_enums import KnownExtensionDataSourceStreams -from ._monitor_management_client_enums import KnownPerfCounterDataSourceStreams -from ._monitor_management_client_enums import KnownSyslogDataSourceFacilityNames -from ._monitor_management_client_enums import KnownSyslogDataSourceLogLevels -from ._monitor_management_client_enums import KnownSyslogDataSourceStreams -from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureMonitorMetricsDestination", - "DataCollectionRule", - "DataCollectionRuleAssociation", - "DataCollectionRuleAssociationProxyOnlyResource", - "DataCollectionRuleAssociationProxyOnlyResourceListResult", - "DataCollectionRuleAssociationProxyOnlyResourceProperties", - "DataCollectionRuleDataSources", - "DataCollectionRuleDestinations", - "DataCollectionRuleResource", - "DataCollectionRuleResourceListResult", - "DataCollectionRuleResourceProperties", - "DataFlow", - "DataSourcesSpec", - "DestinationsSpec", - "DestinationsSpecAzureMonitorMetrics", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "ExtensionDataSource", - "LogAnalyticsDestination", - "PerfCounterDataSource", - "ResourceForUpdate", - "SyslogDataSource", - "WindowsEventLogDataSource", - "KnownDataCollectionRuleAssociationProvisioningState", - "KnownDataCollectionRuleProvisioningState", - "KnownDataCollectionRuleResourceKind", - "KnownDataFlowStreams", - "KnownExtensionDataSourceStreams", - "KnownPerfCounterDataSourceStreams", - "KnownSyslogDataSourceFacilityNames", - "KnownSyslogDataSourceLogLevels", - "KnownSyslogDataSourceStreams", - "KnownWindowsEventLogDataSourceStreams", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py deleted file mode 100644 index 5ae69c5668555..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1160 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class AzureMonitorMetricsDestination(_serialization.Model): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class DataCollectionRule(_serialization.Model): - """Definition of what monitoring data to collect and where that data should be sent. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_sources: 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. - :vartype data_sources: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_sources: 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. - :paramtype data_sources: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataFlow] - """ - super().__init__(**kwargs) - self.description = description - self.immutable_id = None - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleAssociation(_serialization.Model): - """Definition of association of a data collection rule with a monitored Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - """ - super().__init__(**kwargs) - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): - """Definition of generic ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "data_collection_rule_id": {"key": "properties.dataCollectionRuleId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = None - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleAssociationProxyOnlyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRuleAssociation): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - """ - super().__init__(description=description, data_collection_rule_id=data_collection_rule_id, **kwargs) - - -class DataSourcesSpec(_serialization.Model): - """Specification of data sources that will be collected. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2019_11_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2019_11_01_preview.models.ExtensionDataSource] - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2019_11_01_preview.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2019_11_01_preview.models.ExtensionDataSource] - """ - super().__init__(**kwargs) - self.performance_counters = performance_counters - self.windows_event_logs = windows_event_logs - self.syslog = syslog - self.extensions = extensions - - -class DataCollectionRuleDataSources(DataSourcesSpec): - """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. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2019_11_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2019_11_01_preview.models.ExtensionDataSource] - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2019_11_01_preview.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2019_11_01_preview.models.ExtensionDataSource] - """ - super().__init__( - performance_counters=performance_counters, - windows_event_logs=windows_event_logs, - syslog=syslog, - extensions=extensions, - **kwargs - ) - - -class DestinationsSpec(_serialization.Model): - """Specification of destinations that can be used in data flows. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.LogAnalyticsDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.LogAnalyticsDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - super().__init__(**kwargs) - self.log_analytics = log_analytics - self.azure_monitor_metrics = azure_monitor_metrics - - -class DataCollectionRuleDestinations(DestinationsSpec): - """The specification of destinations. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.LogAnalyticsDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.LogAnalyticsDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - super().__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) - - -class DataCollectionRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". - :vartype kind: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_sources: 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. - :vartype data_sources: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "location": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "immutable_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "immutable_id": {"key": "properties.immutableId", "type": "str"}, - "data_sources": {"key": "properties.dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "properties.destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "properties.dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.KnownDataCollectionRuleResourceKind"]] = None, - description: Optional[str] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". - :paramtype kind: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_sources: 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. - :paramtype data_sources: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataFlow] - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.kind = kind - self.id = None - self.name = None - self.type = None - self.etag = None - self.description = description - self.immutable_id = None - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleResourceProperties(DataCollectionRule): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_sources: 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. - :vartype data_sources: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_sources: 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. - :paramtype data_sources: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2019_11_01_preview.models.DataFlow] - """ - super().__init__( - description=description, - data_sources=data_sources, - destinations=destinations, - data_flows=data_flows, - **kwargs - ) - - -class DataFlow(_serialization.Model): - """Definition of which streams are sent to which destinations. - - :ivar streams: List of streams for this data flow. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataFlowStreams] - :ivar destinations: List of destinations for this data flow. - :vartype destinations: list[str] - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "destinations": {"key": "destinations", "type": "[str]"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, - destinations: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: List of streams for this data flow. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownDataFlowStreams] - :keyword destinations: List of destinations for this data flow. - :paramtype destinations: list[str] - """ - super().__init__(**kwargs) - self.streams = streams - self.destinations = destinations - - -class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(name=name, **kwargs) - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2019_11_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.monitor.v2019_11_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2019_11_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2019_11_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class ExtensionDataSource(_serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with - the Azure Monitor Agent. - Collected from either Windows and Linux machines, depending on which extension is defined. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownExtensionDataSourceStreams] - :ivar extension_name: The name of the VM extension. Required. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: JSON - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "extension_name": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "extension_name": {"key": "extensionName", "type": "str"}, - "extension_settings": {"key": "extensionSettings", "type": "object"}, - "input_data_sources": {"key": "inputDataSources", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - extension_name: str, - streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, - extension_settings: Optional[JSON] = None, - input_data_sources: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownExtensionDataSourceStreams] - :keyword extension_name: The name of the VM extension. Required. - :paramtype extension_name: str - :keyword extension_settings: The extension settings. The format is specific for particular - extension. - :paramtype extension_settings: JSON - :keyword input_data_sources: The list of data sources this extension needs data from. - :paramtype input_data_sources: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.extension_name = extension_name - self.extension_settings = extension_settings - self.input_data_sources = input_data_sources - self.name = name - - -class LogAnalyticsDestination(_serialization.Model): - """Log Analytics destination. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. - :vartype workspace_resource_id: str - :ivar workspace_id: The Customer ID of the Log Analytics workspace. - :vartype workspace_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "workspace_id": {"readonly": True}, - } - - _attribute_map = { - "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. - :paramtype workspace_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.workspace_resource_id = workspace_resource_id - self.workspace_id = None - self.name = name - - -class PerfCounterDataSource(_serialization.Model): - """Definition of which performance counters will be collected and how they will be collected by - this data collection rule. - Collected from both Windows and Linux machines where the counter is present. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: 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'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "sampling_frequency_in_seconds": {"key": "samplingFrequencyInSeconds", "type": "int"}, - "counter_specifiers": {"key": "counterSpecifiers", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownPerfCounterDataSourceStreams"]]] = None, - sampling_frequency_in_seconds: Optional[int] = None, - counter_specifiers: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] - :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :paramtype sampling_frequency_in_seconds: int - :keyword counter_specifiers: 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'. - :paramtype counter_specifiers: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.sampling_frequency_in_seconds = sampling_frequency_in_seconds - self.counter_specifiers = counter_specifiers - self.name = name - - -class ResourceForUpdate(_serialization.Model): - """Definition of ARM tracked top level resource properties for update operation. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class SyslogDataSource(_serialization.Model): - """Definition of which syslog data will be collected and how it will be collected. - Only collected from Linux machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "facility_names": {"key": "facilityNames", "type": "[str]"}, - "log_levels": {"key": "logLevels", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownSyslogDataSourceStreams"]]] = None, - facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, - log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownSyslogDataSourceStreams] - :keyword facility_names: The list of facility names. - :paramtype facility_names: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] - :keyword log_levels: The log levels to collect. - :paramtype log_levels: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.facility_names = facility_names - self.log_levels = log_levels - self.name = name - - -class WindowsEventLogDataSource(_serialization.Model): - """Definition of which Windows Event Log events will be collected and how they will be collected. - Only collected from Windows machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "x_path_queries": {"key": "xPathQueries", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, - x_path_queries: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. - :paramtype x_path_queries: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.x_path_queries = x_path_queries - self.name = name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index a1feab4806d0e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource.""" - - LINUX = "Linux" - WINDOWS = "Windows" - - -class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownDataFlowStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownExtensionDataSourceStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownPerfCounterDataSourceStreams.""" - - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - - -class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceFacilityNames.""" - - AUTH = "auth" - AUTHPRIV = "authpriv" - CRON = "cron" - DAEMON = "daemon" - KERN = "kern" - LPR = "lpr" - MAIL = "mail" - MARK = "mark" - NEWS = "news" - SYSLOG = "syslog" - USER = "user" - UUCP = "uucp" - LOCAL0 = "local0" - LOCAL1 = "local1" - LOCAL2 = "local2" - LOCAL3 = "local3" - LOCAL4 = "local4" - LOCAL5 = "local5" - LOCAL6 = "local6" - LOCAL7 = "local7" - ASTERISK = "*" - - -class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceLogLevels.""" - - DEBUG = "Debug" - INFO = "Info" - NOTICE = "Notice" - WARNING = "Warning" - ERROR = "Error" - CRITICAL = "Critical" - ALERT = "Alert" - EMERGENCY = "Emergency" - ASTERISK = "*" - - -class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceStreams.""" - - MICROSOFT_SYSLOG = "Microsoft-Syslog" - - -class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownWindowsEventLogDataSourceStreams.""" - - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py deleted file mode 100644 index cb4e5ea6755ea..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index b0d7674bc0f29..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,672 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_rule_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_11_01_preview.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace - def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py deleted file mode 100644 index 9ed552110b7c4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,876 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2019_11_01_preview.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2019_11_01_preview.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2019_11_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py deleted file mode 100644 index a38a4e1478699..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json deleted file mode 100644 index 3c94faf452bf1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2020-01-01-preview", - "total_api_version_list": ["2020-01-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "management_group_diagnostic_settings": "ManagementGroupDiagnosticSettingsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py deleted file mode 100644 index 8c60f2a9d0917..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,85 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ManagementGroupDiagnosticSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations - operations - :vartype management_group_diagnostic_settings: - azure.mgmt.monitor.v2020_01_01_preview.operations.ManagementGroupDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py deleted file mode 100644 index 3c41728a41135..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 85b824d043e73..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,85 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ManagementGroupDiagnosticSettingsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations - operations - :vartype management_group_diagnostic_settings: - azure.mgmt.monitor.v2020_01_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py deleted file mode 100644 index df848453257bc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ManagementGroupDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py deleted file mode 100644 index 1bdef69a47ed6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ /dev/null @@ -1,415 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._management_group_diagnostic_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ManagementGroupDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2020_01_01_preview.aio.MonitorManagementClient`'s - :attr:`management_group_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, management_group_id: str, name: str, **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Gets the active management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @overload - async def create_or_update( - self, - management_group_id: str, - name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - management_group_id: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - management_group_id: str, - name: str, - parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - ManagementGroupDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") - - request = build_create_or_update_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @distributed_trace - def list( - self, management_group_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagementGroupDiagnosticSettingsResource"]: - """Gets the active management group diagnostic settings list for the specified management group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py deleted file mode 100644 index bb05df8b79bab..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorResponse -from ._models_py3 import ManagementGroupDiagnosticSettingsResource -from ._models_py3 import ManagementGroupDiagnosticSettingsResourceCollection -from ._models_py3 import ManagementGroupLogSettings -from ._models_py3 import ManagementGroupProxyOnlyResource -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorResponse", - "ManagementGroupDiagnosticSettingsResource", - "ManagementGroupDiagnosticSettingsResourceCollection", - "ManagementGroupLogSettings", - "ManagementGroupProxyOnlyResource", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py deleted file mode 100644 index d87ff2c9d569b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py +++ /dev/null @@ -1,235 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ManagementGroupProxyOnlyResource(_serialization.Model): - """A proxy only azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Location of the resource. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Location of the resource. - :paramtype location: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - - -class ManagementGroupDiagnosticSettingsResource(ManagementGroupProxyOnlyResource): - """The management group diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Location of the resource. - :vartype location: str - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to - maintain backwards compatibility. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :vartype event_hub_name: str - :ivar logs: The list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupLogSettings] - :ivar workspace_id: 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. - :vartype workspace_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, - "logs": {"key": "properties.logs", "type": "[ManagementGroupLogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - event_hub_name: Optional[str] = None, - logs: Optional[List["_models.ManagementGroupLogSettings"]] = None, - workspace_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Location of the resource. - :paramtype location: str - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here - to maintain backwards compatibility. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :paramtype event_hub_name: str - :keyword logs: The list of logs settings. - :paramtype logs: - list[~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupLogSettings] - :keyword workspace_id: 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. - :paramtype workspace_id: str - """ - super().__init__(location=location, **kwargs) - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.event_hub_name = event_hub_name - self.logs = logs - self.workspace_id = workspace_id - - -class ManagementGroupDiagnosticSettingsResourceCollection(_serialization.Model): - """Represents a collection of management group diagnostic settings resources. - - :ivar value: The collection of management group diagnostic settings resources. - :vartype value: - list[~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ManagementGroupDiagnosticSettingsResource]"}, - } - - def __init__( - self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection of management group diagnostic settings resources. - :paramtype value: - list[~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] - """ - super().__init__(**kwargs) - self.value = value - - -class ManagementGroupLogSettings(_serialization.Model): - """Part of Management Group diagnostic setting. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: Name of a Management Group Diagnostic Log category for a resource type this - setting is applied to. Required. - :vartype category: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - """ - - _validation = { - "category": {"required": True}, - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, category: str, enabled: bool, **kwargs: Any) -> None: - """ - :keyword category: Name of a Management Group Diagnostic Log category for a resource type this - setting is applied to. Required. - :paramtype category: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.category = category - self.enabled = enabled diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py deleted file mode 100644 index df848453257bc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ManagementGroupDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py deleted file mode 100644 index eed4e536f9e6c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ /dev/null @@ -1,526 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagementGroupDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2020_01_01_preview.MonitorManagementClient`'s - :attr:`management_group_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, management_group_id: str, name: str, **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Gets the active management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @overload - def create_or_update( - self, - management_group_id: str, - name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - management_group_id: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - management_group_id: str, - name: str, - parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - ManagementGroupDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") - - request = build_create_or_update_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" - } - - @distributed_trace - def list( - self, management_group_id: str, **kwargs: Any - ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResource"]: - """Gets the active management group diagnostic settings list for the specified management group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py deleted file mode 100644 index fe6231bcf3249..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json deleted file mode 100644 index 660ad49963d52..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2020-05-01-preview", - "total_api_version_list": ["2020-05-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "scheduled_query_rules": "ScheduledQueryRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py deleted file mode 100644 index 820af6112cc5c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: - azure.mgmt.monitor.v2020_05_01_preview.operations.ScheduledQueryRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py deleted file mode 100644 index 2f135477387fb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 5332b493b426d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: - azure.mgmt.monitor.v2020_05_01_preview.aio.operations.ScheduledQueryRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index e010c281d4fc5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ScheduledQueryRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py deleted file mode 100644 index 5983bcef68038..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py +++ /dev/null @@ -1,654 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._scheduled_query_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ScheduledQueryRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2020_05_01_preview.aio.MonitorManagementClient`'s - :attr:`scheduled_query_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: - """Retrieve a scheduled query rule definitions in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: - """Retrieve scheduled query rule definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: - """Retrieve an scheduled query rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResource, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - ScheduledQueryRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a - ScheduledQueryRuleResourcePatch type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py deleted file mode 100644 index 808b00e8d2db5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import Action -from ._models_py3 import Condition -from ._models_py3 import ConditionFailingPeriods -from ._models_py3 import Dimension -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorContract -from ._models_py3 import ErrorResponse -from ._models_py3 import Resource -from ._models_py3 import ScheduledQueryRuleCriteria -from ._models_py3 import ScheduledQueryRuleResource -from ._models_py3 import ScheduledQueryRuleResourceCollection -from ._models_py3 import ScheduledQueryRuleResourcePatch -from ._models_py3 import TrackedResource - -from ._monitor_management_client_enums import AlertSeverity -from ._monitor_management_client_enums import ConditionOperator -from ._monitor_management_client_enums import DimensionOperator -from ._monitor_management_client_enums import TimeAggregation -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Action", - "Condition", - "ConditionFailingPeriods", - "Dimension", - "ErrorAdditionalInfo", - "ErrorContract", - "ErrorResponse", - "Resource", - "ScheduledQueryRuleCriteria", - "ScheduledQueryRuleResource", - "ScheduledQueryRuleResourceCollection", - "ScheduledQueryRuleResourcePatch", - "TrackedResource", - "AlertSeverity", - "ConditionOperator", - "DimensionOperator", - "TimeAggregation", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py deleted file mode 100644 index 637060da25af5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,762 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Action(_serialization.Model): - """Actions to invoke when the alert fires. - - :ivar action_group_id: Action Group resource Id to invoke when the alert fires. - :vartype action_group_id: str - :ivar web_hook_properties: The properties of a webhook object. - :vartype web_hook_properties: dict[str, str] - """ - - _attribute_map = { - "action_group_id": {"key": "actionGroupId", "type": "str"}, - "web_hook_properties": {"key": "webHookProperties", "type": "{str}"}, - } - - def __init__( - self, - *, - action_group_id: Optional[str] = None, - web_hook_properties: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword action_group_id: Action Group resource Id to invoke when the alert fires. - :paramtype action_group_id: str - :keyword web_hook_properties: The properties of a webhook object. - :paramtype web_hook_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.action_group_id = action_group_id - self.web_hook_properties = web_hook_properties - - -class Condition(_serialization.Model): - """A condition of the scheduled query rule. - - All required parameters must be populated in order to send to Azure. - - :ivar query: Log query alert. - :vartype query: str - :ivar time_aggregation: Aggregation type. Required. Known values are: "Count", "Average", - "Minimum", "Maximum", and "Total". - :vartype time_aggregation: str or - ~azure.mgmt.monitor.v2020_05_01_preview.models.TimeAggregation - :ivar metric_measure_column: The column containing the metric measure number. - :vartype metric_measure_column: str - :ivar resource_id_column: The column containing the resource id. The content of the column must - be a uri formatted as resource id. - :vartype resource_id_column: str - :ivar dimensions: List of Dimensions conditions. - :vartype dimensions: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Dimension] - :ivar operator: The criteria operator. Required. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2020_05_01_preview.models.ConditionOperator - :ivar threshold: the criteria threshold value that activates the alert. Required. - :vartype threshold: float - :ivar failing_periods: The minimum number of violations required within the selected lookback - time window required to raise an alert. - :vartype failing_periods: - ~azure.mgmt.monitor.v2020_05_01_preview.models.ConditionFailingPeriods - """ - - _validation = { - "time_aggregation": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "query": {"key": "query", "type": "str"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "metric_measure_column": {"key": "metricMeasureColumn", "type": "str"}, - "resource_id_column": {"key": "resourceIdColumn", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[Dimension]"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "failing_periods": {"key": "failingPeriods", "type": "ConditionFailingPeriods"}, - } - - def __init__( - self, - *, - time_aggregation: Union[str, "_models.TimeAggregation"], - operator: Union[str, "_models.ConditionOperator"], - threshold: float, - query: Optional[str] = None, - metric_measure_column: Optional[str] = None, - resource_id_column: Optional[str] = None, - dimensions: Optional[List["_models.Dimension"]] = None, - failing_periods: Optional["_models.ConditionFailingPeriods"] = None, - **kwargs: Any - ) -> None: - """ - :keyword query: Log query alert. - :paramtype query: str - :keyword time_aggregation: Aggregation type. Required. Known values are: "Count", "Average", - "Minimum", "Maximum", and "Total". - :paramtype time_aggregation: str or - ~azure.mgmt.monitor.v2020_05_01_preview.models.TimeAggregation - :keyword metric_measure_column: The column containing the metric measure number. - :paramtype metric_measure_column: str - :keyword resource_id_column: The column containing the resource id. The content of the column - must be a uri formatted as resource id. - :paramtype resource_id_column: str - :keyword dimensions: List of Dimensions conditions. - :paramtype dimensions: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Dimension] - :keyword operator: The criteria operator. Required. Known values are: "Equals", "GreaterThan", - "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2020_05_01_preview.models.ConditionOperator - :keyword threshold: the criteria threshold value that activates the alert. Required. - :paramtype threshold: float - :keyword failing_periods: The minimum number of violations required within the selected - lookback time window required to raise an alert. - :paramtype failing_periods: - ~azure.mgmt.monitor.v2020_05_01_preview.models.ConditionFailingPeriods - """ - super().__init__(**kwargs) - self.query = query - self.time_aggregation = time_aggregation - self.metric_measure_column = metric_measure_column - self.resource_id_column = resource_id_column - self.dimensions = dimensions - self.operator = operator - self.threshold = threshold - self.failing_periods = failing_periods - - -class ConditionFailingPeriods(_serialization.Model): - """The minimum number of violations required within the selected lookback time window required to - raise an alert. - - :ivar number_of_evaluation_periods: 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. Default value is 1. - :vartype number_of_evaluation_periods: int - :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be - smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :vartype min_failing_periods_to_alert: int - """ - - _attribute_map = { - "number_of_evaluation_periods": {"key": "numberOfEvaluationPeriods", "type": "int"}, - "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "int"}, - } - - def __init__( - self, *, number_of_evaluation_periods: int = 1, min_failing_periods_to_alert: int = 1, **kwargs: Any - ) -> None: - """ - :keyword number_of_evaluation_periods: 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. Default value is 1. - :paramtype number_of_evaluation_periods: int - :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be - smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :paramtype min_failing_periods_to_alert: int - """ - super().__init__(**kwargs) - self.number_of_evaluation_periods = number_of_evaluation_periods - self.min_failing_periods_to_alert = min_failing_periods_to_alert - - -class Dimension(_serialization.Model): - """Dimension splitting and filtering definition. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the dimension. Required. - :vartype name: str - :ivar operator: Operator for dimension values. Required. Known values are: "Include" and - "Exclude". - :vartype operator: str or ~azure.mgmt.monitor.v2020_05_01_preview.models.DimensionOperator - :ivar values: List of dimension values. Required. - :vartype values: list[str] - """ - - _validation = { - "name": {"required": True}, - "operator": {"required": True}, - "values": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - } - - def __init__( - self, *, name: str, operator: Union[str, "_models.DimensionOperator"], values: List[str], **kwargs: Any - ) -> None: - """ - :keyword name: Name of the dimension. Required. - :paramtype name: str - :keyword operator: Operator for dimension values. Required. Known values are: "Include" and - "Exclude". - :paramtype operator: str or ~azure.mgmt.monitor.v2020_05_01_preview.models.DimensionOperator - :keyword values: List of dimension values. Required. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.operator = operator - self.values = values - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorContract(_serialization.Model): - """Describes the format of Error response. - - :ivar error: The error details. - :vartype error: ~azure.mgmt.monitor.v2020_05_01_preview.models.ErrorResponse - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponse"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error details. - :paramtype error: ~azure.mgmt.monitor.v2020_05_01_preview.models.ErrorResponse - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2020_05_01_preview.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.monitor.v2020_05_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorResponse]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ScheduledQueryRuleCriteria(_serialization.Model): - """The rule criteria that defines the conditions of the scheduled query rule. - - :ivar all_of: A list of conditions to evaluate against the specified scopes. - :vartype all_of: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Condition] - """ - - _attribute_map = { - "all_of": {"key": "allOf", "type": "[Condition]"}, - } - - def __init__(self, *, all_of: Optional[List["_models.Condition"]] = None, **kwargs: Any) -> None: - """ - :keyword all_of: A list of conditions to evaluate against the specified scopes. - :paramtype all_of: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Condition] - """ - super().__init__(**kwargs) - self.all_of = all_of - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class ScheduledQueryRuleResource(TrackedResource): # pylint: disable=too-many-instance-attributes - """The scheduled query rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :vartype kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :ivar created_with_api_version: The api-version used when creating this alert rule. - :vartype created_with_api_version: str - :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. - :vartype is_legacy_log_analytics_rule: bool - :ivar description: The description of the scheduled query rule. - :vartype description: str - :ivar display_name: The display name of the alert rule. - :vartype display_name: str - :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, and 4. - :vartype severity: float or ~azure.mgmt.monitor.v2020_05_01_preview.models.AlertSeverity - :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :vartype enabled: bool - :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. - :vartype scopes: list[str] - :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO - 8601 duration format. - :vartype evaluation_frequency: ~datetime.timedelta - :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). - :vartype window_size: ~datetime.timedelta - :ivar override_query_time_range: If specified then overrides the query time range (default is - WindowSize*NumberOfEvaluationPeriods). - :vartype override_query_time_range: ~datetime.timedelta - :ivar target_resource_types: List of resource type of the target resource(s) on which the alert - is created/updated. For example if the scope is a resource group and targetResourceTypes is - Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. - :vartype target_resource_types: list[str] - :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. - :vartype criteria: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration - format) after the alert is fired. - :vartype mute_actions_duration: ~datetime.timedelta - :ivar actions: - :vartype actions: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Action] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "kind": {"readonly": True}, - "etag": {"readonly": True}, - "created_with_api_version": {"readonly": True}, - "is_legacy_log_analytics_rule": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, - "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "severity": {"key": "properties.severity", "type": "float"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, - "window_size": {"key": "properties.windowSize", "type": "duration"}, - "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, - "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, - "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, - "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, - "actions": {"key": "properties.actions", "type": "[Action]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - display_name: Optional[str] = None, - severity: Optional[Union[float, "_models.AlertSeverity"]] = None, - enabled: Optional[bool] = None, - scopes: Optional[List[str]] = None, - evaluation_frequency: Optional[datetime.timedelta] = None, - window_size: Optional[datetime.timedelta] = None, - override_query_time_range: Optional[datetime.timedelta] = None, - target_resource_types: Optional[List[str]] = None, - criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, - mute_actions_duration: Optional[datetime.timedelta] = None, - actions: Optional[List["_models.Action"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword description: The description of the scheduled query rule. - :paramtype description: str - :keyword display_name: The display name of the alert rule. - :paramtype display_name: str - :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, and 4. - :paramtype severity: float or ~azure.mgmt.monitor.v2020_05_01_preview.models.AlertSeverity - :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :paramtype enabled: bool - :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. - :paramtype scopes: list[str] - :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in - ISO 8601 duration format. - :paramtype evaluation_frequency: ~datetime.timedelta - :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). - :paramtype window_size: ~datetime.timedelta - :keyword override_query_time_range: If specified then overrides the query time range (default - is WindowSize*NumberOfEvaluationPeriods). - :paramtype override_query_time_range: ~datetime.timedelta - :keyword target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. - :paramtype target_resource_types: list[str] - :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. - :paramtype criteria: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 - duration format) after the alert is fired. - :paramtype mute_actions_duration: ~datetime.timedelta - :keyword actions: - :paramtype actions: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Action] - """ - super().__init__(tags=tags, location=location, **kwargs) - self.kind = None - self.etag = None - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = description - self.display_name = display_name - self.severity = severity - self.enabled = enabled - self.scopes = scopes - self.evaluation_frequency = evaluation_frequency - self.window_size = window_size - self.override_query_time_range = override_query_time_range - self.target_resource_types = target_resource_types - self.criteria = criteria - self.mute_actions_duration = mute_actions_duration - self.actions = actions - - -class ScheduledQueryRuleResourceCollection(_serialization.Model): - """Represents a collection of scheduled query rule resources. - - :ivar value: The values for the scheduled query rule resources. - :vartype value: list[~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ScheduledQueryRuleResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The values for the scheduled query rule resources. - :paramtype value: - list[~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource] - """ - super().__init__(**kwargs) - self.value = value - - -class ScheduledQueryRuleResourcePatch(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The scheduled query rule resource for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar created_with_api_version: The api-version used when creating this alert rule. - :vartype created_with_api_version: str - :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. - :vartype is_legacy_log_analytics_rule: bool - :ivar description: The description of the scheduled query rule. - :vartype description: str - :ivar display_name: The display name of the alert rule. - :vartype display_name: str - :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, and 4. - :vartype severity: float or ~azure.mgmt.monitor.v2020_05_01_preview.models.AlertSeverity - :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :vartype enabled: bool - :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. - :vartype scopes: list[str] - :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO - 8601 duration format. - :vartype evaluation_frequency: ~datetime.timedelta - :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). - :vartype window_size: ~datetime.timedelta - :ivar override_query_time_range: If specified then overrides the query time range (default is - WindowSize*NumberOfEvaluationPeriods). - :vartype override_query_time_range: ~datetime.timedelta - :ivar target_resource_types: List of resource type of the target resource(s) on which the alert - is created/updated. For example if the scope is a resource group and targetResourceTypes is - Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. - :vartype target_resource_types: list[str] - :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. - :vartype criteria: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration - format) after the alert is fired. - :vartype mute_actions_duration: ~datetime.timedelta - :ivar actions: - :vartype actions: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Action] - """ - - _validation = { - "created_with_api_version": {"readonly": True}, - "is_legacy_log_analytics_rule": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, - "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "severity": {"key": "properties.severity", "type": "float"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, - "window_size": {"key": "properties.windowSize", "type": "duration"}, - "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, - "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, - "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, - "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, - "actions": {"key": "properties.actions", "type": "[Action]"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - display_name: Optional[str] = None, - severity: Optional[Union[float, "_models.AlertSeverity"]] = None, - enabled: Optional[bool] = None, - scopes: Optional[List[str]] = None, - evaluation_frequency: Optional[datetime.timedelta] = None, - window_size: Optional[datetime.timedelta] = None, - override_query_time_range: Optional[datetime.timedelta] = None, - target_resource_types: Optional[List[str]] = None, - criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, - mute_actions_duration: Optional[datetime.timedelta] = None, - actions: Optional[List["_models.Action"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of the scheduled query rule. - :paramtype description: str - :keyword display_name: The display name of the alert rule. - :paramtype display_name: str - :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Known values are: 0, 1, 2, 3, and 4. - :paramtype severity: float or ~azure.mgmt.monitor.v2020_05_01_preview.models.AlertSeverity - :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :paramtype enabled: bool - :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. - :paramtype scopes: list[str] - :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in - ISO 8601 duration format. - :paramtype evaluation_frequency: ~datetime.timedelta - :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). - :paramtype window_size: ~datetime.timedelta - :keyword override_query_time_range: If specified then overrides the query time range (default - is WindowSize*NumberOfEvaluationPeriods). - :paramtype override_query_time_range: ~datetime.timedelta - :keyword target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. - :paramtype target_resource_types: list[str] - :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. - :paramtype criteria: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 - duration format) after the alert is fired. - :paramtype mute_actions_duration: ~datetime.timedelta - :keyword actions: - :paramtype actions: list[~azure.mgmt.monitor.v2020_05_01_preview.models.Action] - """ - super().__init__(**kwargs) - self.tags = tags - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = description - self.display_name = display_name - self.severity = severity - self.enabled = enabled - self.scopes = scopes - self.evaluation_frequency = evaluation_frequency - self.window_size = window_size - self.override_query_time_range = override_query_time_range - self.target_resource_types = target_resource_types - self.criteria = criteria - self.mute_actions_duration = mute_actions_duration - self.actions = actions diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 745c9374e7d60..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AlertSeverity(float, Enum, metaclass=CaseInsensitiveEnumMeta): - """Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest.""" - - ZERO = 0 - ONE = 1 - TWO = 2 - THREE = 3 - FOUR = 4 - - -class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The criteria operator.""" - - EQUALS = "Equals" - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class DimensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operator for dimension values.""" - - INCLUDE = "Include" - EXCLUDE = "Exclude" - - -class TimeAggregation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation type.""" - - COUNT = "Count" - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py deleted file mode 100644 index e010c281d4fc5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ScheduledQueryRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py deleted file mode 100644 index d228d7b32971a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py +++ /dev/null @@ -1,837 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ScheduledQueryRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2020_05_01_preview.MonitorManagementClient`'s - :attr:`scheduled_query_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ScheduledQueryRuleResource"]: - """Retrieve a scheduled query rule definitions in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ScheduledQueryRuleResource"]: - """Retrieve scheduled query rule definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: - """Retrieve an scheduled query rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResource, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - ScheduledQueryRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a - ScheduledQueryRuleResourcePatch type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_05_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py deleted file mode 100644 index fddd1844a56b5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json deleted file mode 100644 index 8310acd4e00ce..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2020-10-01", - "total_api_version_list": ["2020-10-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "activity_log_alerts": "ActivityLogAlertsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py deleted file mode 100644 index ee3137b48e312..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogAlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: - azure.mgmt.monitor.v2020_10_01.operations.ActivityLogAlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py deleted file mode 100644 index 42b631fd85946..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py deleted file mode 100644 index a39bf9bd18bec..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogAlertsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: - azure.mgmt.monitor.v2020_10_01.aio.operations.ActivityLogAlertsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py deleted file mode 100644 index b024a2af0682a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._activity_log_alerts_operations import ActivityLogAlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivityLogAlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py deleted file mode 100644 index 5fae3dda74184..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py +++ /dev/null @@ -1,664 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._activity_log_alerts_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActivityLogAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2020_10_01.aio.MonitorManagementClient`'s - :attr:`activity_log_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule: _models.ActivityLogAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new Activity Log Alert rule or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. - Required. - :type activity_log_alert_rule: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new Activity Log Alert rule or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. - Required. - :type activity_log_alert_rule: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule: Union[_models.ActivityLogAlertResource, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new Activity Log Alert rule or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. Is - either a ActivityLogAlertResource type or a IO type. Required. - :type activity_log_alert_rule: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_rule, (IO, bytes)): - _content = activity_log_alert_rule - else: - _json = self._serialize.body(activity_log_alert_rule, "ActivityLogAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Get an Activity Log Alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> None: - """Delete an Activity Log Alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @overload - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule_patch: _models.AlertRulePatchObject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update - the Alert rule tags, and to enable or disable the Alert rule. To update other fields use - CreateOrUpdate operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_rule_patch: - ~azure.mgmt.monitor.v2020_10_01.models.AlertRulePatchObject - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update - the Alert rule tags, and to enable or disable the Alert rule. To update other fields use - CreateOrUpdate operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_rule_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule_patch: Union[_models.AlertRulePatchObject, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update - the Alert rule tags, and to enable or disable the Alert rule. To update other fields use - CreateOrUpdate operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a - AlertRulePatchObject type or a IO type. Required. - :type activity_log_alert_rule_patch: - ~azure.mgmt.monitor.v2020_10_01.models.AlertRulePatchObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_rule_patch, (IO, bytes)): - _content = activity_log_alert_rule_patch - else: - _json = self._serialize.body(activity_log_alert_rule_patch, "AlertRulePatchObject") - - request = build_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: - """Get a list of all Activity Log Alert rules in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActivityLogAlertResource"]: - """Get a list of all Activity Log Alert rules in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py deleted file mode 100644 index 68b921674c5d2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionGroup -from ._models_py3 import ActionList -from ._models_py3 import ActivityLogAlertResource -from ._models_py3 import AlertRuleAllOfCondition -from ._models_py3 import AlertRuleAnyOfOrLeafCondition -from ._models_py3 import AlertRuleLeafCondition -from ._models_py3 import AlertRuleList -from ._models_py3 import AlertRulePatchObject -from ._models_py3 import AzureResource -from ._models_py3 import ErrorResponse -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroup", - "ActionList", - "ActivityLogAlertResource", - "AlertRuleAllOfCondition", - "AlertRuleAnyOfOrLeafCondition", - "AlertRuleLeafCondition", - "AlertRuleList", - "AlertRulePatchObject", - "AzureResource", - "ErrorResponse", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py deleted file mode 100644 index c5d3588a63b56..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py +++ /dev/null @@ -1,443 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionGroup(_serialization.Model): - """A pointer to an Azure Action Group. - - All required parameters must be populated in order to send to Azure. - - :ivar action_group_id: The resource ID of the Action Group. This cannot be null or empty. - Required. - :vartype action_group_id: str - :ivar webhook_properties: the dictionary of custom properties to include with the post - operation. These data are appended to the webhook payload. - :vartype webhook_properties: dict[str, str] - """ - - _validation = { - "action_group_id": {"required": True}, - } - - _attribute_map = { - "action_group_id": {"key": "actionGroupId", "type": "str"}, - "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, - } - - def __init__( - self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword action_group_id: The resource ID of the Action Group. This cannot be null or empty. - Required. - :paramtype action_group_id: str - :keyword webhook_properties: the dictionary of custom properties to include with the post - operation. These data are appended to the webhook payload. - :paramtype webhook_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.action_group_id = action_group_id - self.webhook_properties = webhook_properties - - -class ActionList(_serialization.Model): - """A list of Activity Log Alert rule actions. - - :ivar action_groups: The list of the Action Groups. - :vartype action_groups: list[~azure.mgmt.monitor.v2020_10_01.models.ActionGroup] - """ - - _attribute_map = { - "action_groups": {"key": "actionGroups", "type": "[ActionGroup]"}, - } - - def __init__(self, *, action_groups: Optional[List["_models.ActionGroup"]] = None, **kwargs: Any) -> None: - """ - :keyword action_groups: The list of the Action Groups. - :paramtype action_groups: list[~azure.mgmt.monitor.v2020_10_01.models.ActionGroup] - """ - super().__init__(**kwargs) - self.action_groups = action_groups - - -class AzureResource(_serialization.Model): - """An Azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource Id. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global - service, the location of the rules should always be 'global'. - :vartype location: str - :ivar tags: The tags of the resource. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str = "global", tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global - service, the location of the rules should always be 'global'. - :paramtype location: str - :keyword tags: The tags of the resource. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActivityLogAlertResource(AzureResource): - """An Activity Log Alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource Id. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global - service, the location of the rules should always be 'global'. - :vartype location: str - :ivar tags: The tags of the resource. - :vartype tags: dict[str, str] - :ivar scopes: A list of resource IDs that will be used as prefixes. The alert will only apply - to Activity Log events with resource IDs that fall under one of these prefixes. This list must - include at least one item. - :vartype scopes: list[str] - :ivar condition: The condition that will cause this alert to activate. - :vartype condition: ~azure.mgmt.monitor.v2020_10_01.models.AlertRuleAllOfCondition - :ivar actions: The actions that will activate when the condition is met. - :vartype actions: ~azure.mgmt.monitor.v2020_10_01.models.ActionList - :ivar enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log - Alert rule is not enabled, then none of its actions will be activated. - :vartype enabled: bool - :ivar description: A description of this Activity Log Alert rule. - :vartype description: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "condition": {"key": "properties.condition", "type": "AlertRuleAllOfCondition"}, - "actions": {"key": "properties.actions", "type": "ActionList"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - } - - def __init__( - self, - *, - location: str = "global", - tags: Optional[Dict[str, str]] = None, - scopes: Optional[List[str]] = None, - condition: Optional["_models.AlertRuleAllOfCondition"] = None, - actions: Optional["_models.ActionList"] = None, - enabled: bool = True, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global - service, the location of the rules should always be 'global'. - :paramtype location: str - :keyword tags: The tags of the resource. - :paramtype tags: dict[str, str] - :keyword scopes: A list of resource IDs that will be used as prefixes. The alert will only - apply to Activity Log events with resource IDs that fall under one of these prefixes. This list - must include at least one item. - :paramtype scopes: list[str] - :keyword condition: The condition that will cause this alert to activate. - :paramtype condition: ~azure.mgmt.monitor.v2020_10_01.models.AlertRuleAllOfCondition - :keyword actions: The actions that will activate when the condition is met. - :paramtype actions: ~azure.mgmt.monitor.v2020_10_01.models.ActionList - :keyword enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log - Alert rule is not enabled, then none of its actions will be activated. - :paramtype enabled: bool - :keyword description: A description of this Activity Log Alert rule. - :paramtype description: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.scopes = scopes - self.condition = condition - self.actions = actions - self.enabled = enabled - self.description = description - - -class AlertRuleAllOfCondition(_serialization.Model): - """An Activity Log Alert rule condition that is met when all its member conditions are met. - - All required parameters must be populated in order to send to Azure. - - :ivar all_of: The list of Activity Log Alert rule conditions. Required. - :vartype all_of: list[~azure.mgmt.monitor.v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] - """ - - _validation = { - "all_of": {"required": True}, - } - - _attribute_map = { - "all_of": {"key": "allOf", "type": "[AlertRuleAnyOfOrLeafCondition]"}, - } - - def __init__(self, *, all_of: List["_models.AlertRuleAnyOfOrLeafCondition"], **kwargs: Any) -> None: - """ - :keyword all_of: The list of Activity Log Alert rule conditions. Required. - :paramtype all_of: list[~azure.mgmt.monitor.v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] - """ - super().__init__(**kwargs) - self.all_of = all_of - - -class AlertRuleLeafCondition(_serialization.Model): - """An Activity Log Alert rule condition that is met by comparing the field and value of an - Activity Log event. - This condition must contain 'field' and either 'equals' or 'containsAny'. - - :ivar field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :vartype field: str - :ivar equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :vartype equals: str - :ivar contains_any: The value of the event's field will be compared to the values in this array - (case-insensitive) to determine if the condition is met. - :vartype contains_any: list[str] - """ - - _attribute_map = { - "field": {"key": "field", "type": "str"}, - "equals": {"key": "equals", "type": "str"}, - "contains_any": {"key": "containsAny", "type": "[str]"}, - } - - def __init__( - self, - *, - field: Optional[str] = None, - equals: Optional[str] = None, - contains_any: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :paramtype field: str - :keyword equals: The value of the event's field will be compared to this value - (case-insensitive) to determine if the condition is met. - :paramtype equals: str - :keyword contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :paramtype contains_any: list[str] - """ - super().__init__(**kwargs) - self.field = field - self.equals = equals - self.contains_any = contains_any - - -class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): - """An Activity Log Alert rule condition that is met when all its member conditions are met. - Each condition can be of one of the following types: - **Important**\ : Each type has its unique subset of properties. Properties from different types - CANNOT exist in one condition. - - - * **Leaf Condition -** must contain 'field' and either 'equals' or 'containsAny'. - *Please note, 'anyOf' should **not** be set in a Leaf Condition.* - - * **AnyOf Condition -** must contain **only** 'anyOf' (which is an array of Leaf Conditions). - *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf - Condition.*. - - :ivar field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :vartype field: str - :ivar equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :vartype equals: str - :ivar contains_any: The value of the event's field will be compared to the values in this array - (case-insensitive) to determine if the condition is met. - :vartype contains_any: list[str] - :ivar any_of: An Activity Log Alert rule condition that is met when at least one of its member - leaf conditions are met. - :vartype any_of: list[~azure.mgmt.monitor.v2020_10_01.models.AlertRuleLeafCondition] - """ - - _attribute_map = { - "field": {"key": "field", "type": "str"}, - "equals": {"key": "equals", "type": "str"}, - "contains_any": {"key": "containsAny", "type": "[str]"}, - "any_of": {"key": "anyOf", "type": "[AlertRuleLeafCondition]"}, - } - - def __init__( - self, - *, - field: Optional[str] = None, - equals: Optional[str] = None, - contains_any: Optional[List[str]] = None, - any_of: Optional[List["_models.AlertRuleLeafCondition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :paramtype field: str - :keyword equals: The value of the event's field will be compared to this value - (case-insensitive) to determine if the condition is met. - :paramtype equals: str - :keyword contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :paramtype contains_any: list[str] - :keyword any_of: An Activity Log Alert rule condition that is met when at least one of its - member leaf conditions are met. - :paramtype any_of: list[~azure.mgmt.monitor.v2020_10_01.models.AlertRuleLeafCondition] - """ - super().__init__(field=field, equals=equals, contains_any=contains_any, **kwargs) - self.any_of = any_of - - -class AlertRuleList(_serialization.Model): - """A list of Activity Log Alert rules. - - :ivar value: The list of Activity Log Alert rules. - :vartype value: list[~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActivityLogAlertResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of Activity Log Alert rules. - :paramtype value: list[~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AlertRulePatchObject(_serialization.Model): - """An Activity Log Alert rule object for the body of patch operations. - - :ivar tags: The resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log - Alert rule is not enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: The resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log - Alert rule is not enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class ErrorResponse(_serialization.Model): - """The error response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message indicating why the operation failed. - :vartype message: str - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py deleted file mode 100644 index b024a2af0682a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._activity_log_alerts_operations import ActivityLogAlertsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivityLogAlertsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py deleted file mode 100644 index 51efebd9b92dd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py +++ /dev/null @@ -1,851 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, activity_log_alert_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActivityLogAlertsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2020_10_01.MonitorManagementClient`'s - :attr:`activity_log_alerts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule: _models.ActivityLogAlertResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new Activity Log Alert rule or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. - Required. - :type activity_log_alert_rule: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new Activity Log Alert rule or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. - Required. - :type activity_log_alert_rule: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule: Union[_models.ActivityLogAlertResource, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Create a new Activity Log Alert rule or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. Is - either a ActivityLogAlertResource type or a IO type. Required. - :type activity_log_alert_rule: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_rule, (IO, bytes)): - _content = activity_log_alert_rule - else: - _json = self._serialize.body(activity_log_alert_rule, "ActivityLogAlertResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def get( - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Get an Activity Log Alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> None: - """Delete an Activity Log Alert rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @overload - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule_patch: _models.AlertRulePatchObject, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update - the Alert rule tags, and to enable or disable the Alert rule. To update other fields use - CreateOrUpdate operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_rule_patch: - ~azure.mgmt.monitor.v2020_10_01.models.AlertRulePatchObject - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update - the Alert rule tags, and to enable or disable the Alert rule. To update other fields use - CreateOrUpdate operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Required. - :type activity_log_alert_rule_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - activity_log_alert_name: str, - activity_log_alert_rule_patch: Union[_models.AlertRulePatchObject, IO], - **kwargs: Any - ) -> _models.ActivityLogAlertResource: - """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update - the Alert rule tags, and to enable or disable the Alert rule. To update other fields use - CreateOrUpdate operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. - :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a - AlertRulePatchObject type or a IO type. Required. - :type activity_log_alert_rule_patch: - ~azure.mgmt.monitor.v2020_10_01.models.AlertRulePatchObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActivityLogAlertResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(activity_log_alert_rule_patch, (IO, bytes)): - _content = activity_log_alert_rule_patch - else: - _json = self._serialize.body(activity_log_alert_rule_patch, "AlertRulePatchObject") - - request = build_update_request( - resource_group_name=resource_group_name, - activity_log_alert_name=activity_log_alert_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: - """Get a list of all Activity Log Alert rules in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActivityLogAlertResource"]: - """Get a list of all Activity Log Alert rules in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActivityLogAlertResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2020_10_01.models.ActivityLogAlertResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) - cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AlertRuleList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py deleted file mode 100644 index 7299d9a2317f8..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json deleted file mode 100644 index 9781de4998c93..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2021-04-01", - "total_api_version_list": ["2021-04-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "data_collection_endpoints": "DataCollectionEndpointsOperations", - "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", - "data_collection_rules": "DataCollectionRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py deleted file mode 100644 index 6dc1fd7840cb9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - DataCollectionEndpointsOperations, - DataCollectionRuleAssociationsOperations, - DataCollectionRulesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: - azure.mgmt.monitor.v2021_04_01.operations.DataCollectionEndpointsOperations - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2021_04_01.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2021_04_01.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py deleted file mode 100644 index 65ce5c4436802..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py deleted file mode 100644 index 29882f3f0543c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - DataCollectionEndpointsOperations, - DataCollectionRuleAssociationsOperations, - DataCollectionRulesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: - azure.mgmt.monitor.v2021_04_01.aio.operations.DataCollectionEndpointsOperations - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2021_04_01.aio.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2021_04_01.aio.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py deleted file mode 100644 index 842046dd09e5f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._data_collection_endpoints_operations import DataCollectionEndpointsOperations -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataCollectionEndpointsOperations", - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py deleted file mode 100644 index ecffa05e321aa..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_endpoints_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_04_01.aio.MonitorManagementClient`'s - :attr:`data_collection_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified resource group. - - Lists all data collection endpoints in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified subscription. - - Lists all data collection endpoints in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Returns the specified data collection endpoint. - - Returns the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.DataCollectionEndpointResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionEndpointResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection endpoint. - - Deletes a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index c46841eecdfee..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,530 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rule_associations_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_request, - build_list_by_rule_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_04_01.aio.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace_async - async def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py deleted file mode 100644 index 45c77f5cb0c81..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rules_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_04_01.aio.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py deleted file mode 100644 index 69ec359db511b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py +++ /dev/null @@ -1,121 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AzureMonitorMetricsDestination -from ._models_py3 import ConfigurationAccessEndpointSpec -from ._models_py3 import DataCollectionEndpoint -from ._models_py3 import DataCollectionEndpointConfigurationAccess -from ._models_py3 import DataCollectionEndpointLogsIngestion -from ._models_py3 import DataCollectionEndpointNetworkAcls -from ._models_py3 import DataCollectionEndpointResource -from ._models_py3 import DataCollectionEndpointResourceListResult -from ._models_py3 import DataCollectionEndpointResourceProperties -from ._models_py3 import DataCollectionEndpointResourceSystemData -from ._models_py3 import DataCollectionRule -from ._models_py3 import DataCollectionRuleAssociation -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceSystemData -from ._models_py3 import DataCollectionRuleDataSources -from ._models_py3 import DataCollectionRuleDestinations -from ._models_py3 import DataCollectionRuleResource -from ._models_py3 import DataCollectionRuleResourceListResult -from ._models_py3 import DataCollectionRuleResourceProperties -from ._models_py3 import DataCollectionRuleResourceSystemData -from ._models_py3 import DataFlow -from ._models_py3 import DataSourcesSpec -from ._models_py3 import DestinationsSpec -from ._models_py3 import DestinationsSpecAzureMonitorMetrics -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponseCommonV2 -from ._models_py3 import ExtensionDataSource -from ._models_py3 import LogAnalyticsDestination -from ._models_py3 import LogsIngestionEndpointSpec -from ._models_py3 import NetworkRuleSet -from ._models_py3 import PerfCounterDataSource -from ._models_py3 import ResourceForUpdate -from ._models_py3 import SyslogDataSource -from ._models_py3 import SystemData -from ._models_py3 import WindowsEventLogDataSource - -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import KnownDataCollectionEndpointProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionEndpointResourceKind -from ._monitor_management_client_enums import KnownDataCollectionRuleAssociationProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleResourceKind -from ._monitor_management_client_enums import KnownDataFlowStreams -from ._monitor_management_client_enums import KnownExtensionDataSourceStreams -from ._monitor_management_client_enums import KnownPerfCounterDataSourceStreams -from ._monitor_management_client_enums import KnownPublicNetworkAccessOptions -from ._monitor_management_client_enums import KnownSyslogDataSourceFacilityNames -from ._monitor_management_client_enums import KnownSyslogDataSourceLogLevels -from ._monitor_management_client_enums import KnownSyslogDataSourceStreams -from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureMonitorMetricsDestination", - "ConfigurationAccessEndpointSpec", - "DataCollectionEndpoint", - "DataCollectionEndpointConfigurationAccess", - "DataCollectionEndpointLogsIngestion", - "DataCollectionEndpointNetworkAcls", - "DataCollectionEndpointResource", - "DataCollectionEndpointResourceListResult", - "DataCollectionEndpointResourceProperties", - "DataCollectionEndpointResourceSystemData", - "DataCollectionRule", - "DataCollectionRuleAssociation", - "DataCollectionRuleAssociationProxyOnlyResource", - "DataCollectionRuleAssociationProxyOnlyResourceListResult", - "DataCollectionRuleAssociationProxyOnlyResourceProperties", - "DataCollectionRuleAssociationProxyOnlyResourceSystemData", - "DataCollectionRuleDataSources", - "DataCollectionRuleDestinations", - "DataCollectionRuleResource", - "DataCollectionRuleResourceListResult", - "DataCollectionRuleResourceProperties", - "DataCollectionRuleResourceSystemData", - "DataFlow", - "DataSourcesSpec", - "DestinationsSpec", - "DestinationsSpecAzureMonitorMetrics", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponseCommonV2", - "ExtensionDataSource", - "LogAnalyticsDestination", - "LogsIngestionEndpointSpec", - "NetworkRuleSet", - "PerfCounterDataSource", - "ResourceForUpdate", - "SyslogDataSource", - "SystemData", - "WindowsEventLogDataSource", - "CreatedByType", - "KnownDataCollectionEndpointProvisioningState", - "KnownDataCollectionEndpointResourceKind", - "KnownDataCollectionRuleAssociationProvisioningState", - "KnownDataCollectionRuleProvisioningState", - "KnownDataCollectionRuleResourceKind", - "KnownDataFlowStreams", - "KnownExtensionDataSourceStreams", - "KnownPerfCounterDataSourceStreams", - "KnownPublicNetworkAccessOptions", - "KnownSyslogDataSourceFacilityNames", - "KnownSyslogDataSourceLogLevels", - "KnownSyslogDataSourceStreams", - "KnownWindowsEventLogDataSourceStreams", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py deleted file mode 100644 index d1e806110d5fd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py +++ /dev/null @@ -1,1911 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class AzureMonitorMetricsDestination(_serialization.Model): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class ConfigurationAccessEndpointSpec(_serialization.Model): - """Definition of the endpoint used for accessing configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpoint(_serialization.Model): - """Definition of data collection endpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by agents to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointLogsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, - "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by agents to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointLogsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointNetworkAcls - """ - super().__init__(**kwargs) - self.description = description - self.immutable_id = immutable_id - self.configuration_access = configuration_access - self.logs_ingestion = logs_ingestion - self.network_acls = network_acls - self.provisioning_state = None - - -class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec): - """The endpoint used by agents to access their configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class LogsIngestionEndpointSpec(_serialization.Model): - """Definition of the endpoint used for ingesting logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): - """The endpoint used by clients to ingest logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class NetworkRuleSet(_serialization.Model): - """Definition of the network rules. - - :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownPublicNetworkAccessOptions - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class DataCollectionEndpointNetworkAcls(NetworkRuleSet): - """Network access control rules for the endpoints. - - :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownPublicNetworkAccessOptions - """ - super().__init__(public_network_access=public_network_access, **kwargs) - - -class DataCollectionEndpointResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". - :vartype kind: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionEndpointResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResourceSystemData - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by agents to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointLogsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - "location": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionEndpointResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "immutable_id": {"key": "properties.immutableId", "type": "str"}, - "configuration_access": { - "key": "properties.configurationAccess", - "type": "DataCollectionEndpointConfigurationAccess", - }, - "logs_ingestion": {"key": "properties.logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "network_acls": {"key": "properties.networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.KnownDataCollectionEndpointResourceKind"]] = None, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". - :paramtype kind: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionEndpointResourceKind - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by agents to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointLogsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointNetworkAcls - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.kind = kind - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.immutable_id = immutable_id - self.configuration_access = configuration_access - self.logs_ingestion = logs_ingestion - self.network_acls = network_acls - self.provisioning_state = None - - -class DataCollectionEndpointResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionEndpointResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: list[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by agents to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointLogsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, - "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by agents to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointLogsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointNetworkAcls - """ - super().__init__( - description=description, - immutable_id=immutable_id, - configuration_access=configuration_access, - logs_ingestion=logs_ingestion, - network_acls=network_acls, - **kwargs - ) - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class DataCollectionEndpointResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataCollectionRule(_serialization.Model): - """Definition of what monitoring data to collect and where that data should be sent. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_sources: 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. - :vartype data_sources: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2021_04_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_sources: 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. - :paramtype data_sources: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2021_04_01.models.DataFlow] - """ - super().__init__(**kwargs) - self.description = description - self.immutable_id = None - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleAssociation(_serialization.Model): - """Definition of association of a data collection rule with a monitored Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__(**kwargs) - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.data_collection_endpoint_id = data_collection_endpoint_id - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): - """Definition of generic ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceSystemData - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionRuleAssociationProxyOnlyResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "data_collection_rule_id": {"key": "properties.dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.data_collection_endpoint_id = data_collection_endpoint_id - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: - list[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleAssociationProxyOnlyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRuleAssociation): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__( - description=description, - data_collection_rule_id=data_collection_rule_id, - data_collection_endpoint_id=data_collection_endpoint_id, - **kwargs - ) - - -class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataSourcesSpec(_serialization.Model): - """Specification of data sources that will be collected. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2021_04_01.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2021_04_01.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2021_04_01.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2021_04_01.models.ExtensionDataSource] - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2021_04_01.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2021_04_01.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2021_04_01.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2021_04_01.models.ExtensionDataSource] - """ - super().__init__(**kwargs) - self.performance_counters = performance_counters - self.windows_event_logs = windows_event_logs - self.syslog = syslog - self.extensions = extensions - - -class DataCollectionRuleDataSources(DataSourcesSpec): - """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. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2021_04_01.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2021_04_01.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2021_04_01.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2021_04_01.models.ExtensionDataSource] - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2021_04_01.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2021_04_01.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2021_04_01.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2021_04_01.models.ExtensionDataSource] - """ - super().__init__( - performance_counters=performance_counters, - windows_event_logs=windows_event_logs, - syslog=syslog, - extensions=extensions, - **kwargs - ) - - -class DestinationsSpec(_serialization.Model): - """Specification of destinations that can be used in data flows. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: list[~azure.mgmt.monitor.v2021_04_01.models.LogAnalyticsDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2021_04_01.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: list[~azure.mgmt.monitor.v2021_04_01.models.LogAnalyticsDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2021_04_01.models.DestinationsSpecAzureMonitorMetrics - """ - super().__init__(**kwargs) - self.log_analytics = log_analytics - self.azure_monitor_metrics = azure_monitor_metrics - - -class DataCollectionRuleDestinations(DestinationsSpec): - """The specification of destinations. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: list[~azure.mgmt.monitor.v2021_04_01.models.LogAnalyticsDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2021_04_01.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: list[~azure.mgmt.monitor.v2021_04_01.models.LogAnalyticsDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2021_04_01.models.DestinationsSpecAzureMonitorMetrics - """ - super().__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) - - -class DataCollectionRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". - :vartype kind: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResourceSystemData - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_sources: 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. - :vartype data_sources: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2021_04_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "location": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "immutable_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionRuleResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "immutable_id": {"key": "properties.immutableId", "type": "str"}, - "data_sources": {"key": "properties.dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "properties.destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "properties.dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.KnownDataCollectionRuleResourceKind"]] = None, - description: Optional[str] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". - :paramtype kind: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleResourceKind - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_sources: 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. - :paramtype data_sources: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2021_04_01.models.DataFlow] - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.kind = kind - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.immutable_id = None - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: list[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleResourceProperties(DataCollectionRule): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_sources: 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. - :vartype data_sources: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2021_04_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_sources: 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. - :paramtype data_sources: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2021_04_01.models.DataFlow] - """ - super().__init__( - description=description, - data_sources=data_sources, - destinations=destinations, - data_flows=data_flows, - **kwargs - ) - - -class DataCollectionRuleResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2021_04_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataFlow(_serialization.Model): - """Definition of which streams are sent to which destinations. - - :ivar streams: List of streams for this data flow. - :vartype streams: list[str or ~azure.mgmt.monitor.v2021_04_01.models.KnownDataFlowStreams] - :ivar destinations: List of destinations for this data flow. - :vartype destinations: list[str] - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "destinations": {"key": "destinations", "type": "[str]"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, - destinations: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: List of streams for this data flow. - :paramtype streams: list[str or ~azure.mgmt.monitor.v2021_04_01.models.KnownDataFlowStreams] - :keyword destinations: List of destinations for this data flow. - :paramtype destinations: list[str] - """ - super().__init__(**kwargs) - self.streams = streams - self.destinations = destinations - - -class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(name=name, **kwargs) - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2021_04_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.monitor.v2021_04_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponseCommonV2(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2021_04_01.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2021_04_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class ExtensionDataSource(_serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with - the Azure Monitor Agent. - Collected from either Windows and Linux machines, depending on which extension is defined. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownExtensionDataSourceStreams] - :ivar extension_name: The name of the VM extension. Required. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: JSON - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "extension_name": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "extension_name": {"key": "extensionName", "type": "str"}, - "extension_settings": {"key": "extensionSettings", "type": "object"}, - "input_data_sources": {"key": "inputDataSources", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - extension_name: str, - streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, - extension_settings: Optional[JSON] = None, - input_data_sources: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownExtensionDataSourceStreams] - :keyword extension_name: The name of the VM extension. Required. - :paramtype extension_name: str - :keyword extension_settings: The extension settings. The format is specific for particular - extension. - :paramtype extension_settings: JSON - :keyword input_data_sources: The list of data sources this extension needs data from. - :paramtype input_data_sources: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.extension_name = extension_name - self.extension_settings = extension_settings - self.input_data_sources = input_data_sources - self.name = name - - -class LogAnalyticsDestination(_serialization.Model): - """Log Analytics destination. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. - :vartype workspace_resource_id: str - :ivar workspace_id: The Customer ID of the Log Analytics workspace. - :vartype workspace_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "workspace_id": {"readonly": True}, - } - - _attribute_map = { - "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. - :paramtype workspace_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.workspace_resource_id = workspace_resource_id - self.workspace_id = None - self.name = name - - -class PerfCounterDataSource(_serialization.Model): - """Definition of which performance counters will be collected and how they will be collected by - this data collection rule. - Collected from both Windows and Linux machines where the counter is present. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: 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'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "sampling_frequency_in_seconds": {"key": "samplingFrequencyInSeconds", "type": "int"}, - "counter_specifiers": {"key": "counterSpecifiers", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownPerfCounterDataSourceStreams"]]] = None, - sampling_frequency_in_seconds: Optional[int] = None, - counter_specifiers: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownPerfCounterDataSourceStreams] - :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :paramtype sampling_frequency_in_seconds: int - :keyword counter_specifiers: 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'. - :paramtype counter_specifiers: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.sampling_frequency_in_seconds = sampling_frequency_in_seconds - self.counter_specifiers = counter_specifiers - self.name = name - - -class ResourceForUpdate(_serialization.Model): - """Definition of ARM tracked top level resource properties for update operation. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class SyslogDataSource(_serialization.Model): - """Definition of which syslog data will be collected and how it will be collected. - Only collected from Linux machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "facility_names": {"key": "facilityNames", "type": "[str]"}, - "log_levels": {"key": "logLevels", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownSyslogDataSourceStreams"]]] = None, - facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, - log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownSyslogDataSourceStreams] - :keyword facility_names: The list of facility names. - :paramtype facility_names: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownSyslogDataSourceFacilityNames] - :keyword log_levels: The log levels to collect. - :paramtype log_levels: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownSyslogDataSourceLogLevels] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.facility_names = facility_names - self.log_levels = log_levels - self.name = name - - -class WindowsEventLogDataSource(_serialization.Model): - """Definition of which Windows Event Log events will be collected and how they will be collected. - Only collected from Windows machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "x_path_queries": {"key": "xPathQueries", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, - x_path_queries: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] - :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. - :paramtype x_path_queries: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.x_path_queries = x_path_queries - self.name = name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py deleted file mode 100644 index c9edaf22bd950..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,152 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. This property is READ-ONLY.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionEndpointResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource.""" - - LINUX = "Linux" - WINDOWS = "Windows" - - -class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource.""" - - LINUX = "Linux" - WINDOWS = "Windows" - - -class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownDataFlowStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownExtensionDataSourceStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownPerfCounterDataSourceStreams.""" - - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - - -class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The configuration to set whether network access from public internet to the endpoints are - allowed. - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceFacilityNames.""" - - AUTH = "auth" - AUTHPRIV = "authpriv" - CRON = "cron" - DAEMON = "daemon" - KERN = "kern" - LPR = "lpr" - MAIL = "mail" - MARK = "mark" - NEWS = "news" - SYSLOG = "syslog" - USER = "user" - UUCP = "uucp" - LOCAL0 = "local0" - LOCAL1 = "local1" - LOCAL2 = "local2" - LOCAL3 = "local3" - LOCAL4 = "local4" - LOCAL5 = "local5" - LOCAL6 = "local6" - LOCAL7 = "local7" - ASTERISK = "*" - - -class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceLogLevels.""" - - DEBUG = "Debug" - INFO = "Info" - NOTICE = "Notice" - WARNING = "Warning" - ERROR = "Error" - CRITICAL = "Critical" - ALERT = "Alert" - EMERGENCY = "Emergency" - ASTERISK = "*" - - -class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceStreams.""" - - MICROSOFT_SYSLOG = "Microsoft-Syslog" - - -class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownWindowsEventLogDataSourceStreams.""" - - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py deleted file mode 100644 index 842046dd09e5f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._data_collection_endpoints_operations import DataCollectionEndpointsOperations -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataCollectionEndpointsOperations", - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py deleted file mode 100644 index 275196ff00b7f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py +++ /dev/null @@ -1,884 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_04_01.MonitorManagementClient`'s - :attr:`data_collection_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified resource group. - - Lists all data collection endpoints in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified subscription. - - Lists all data collection endpoints in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Returns the specified data collection endpoint. - - Returns the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.DataCollectionEndpointResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionEndpointResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection endpoint. - - Deletes a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index 325f312c5f89f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,667 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_rule_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_04_01.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace - def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py deleted file mode 100644 index 0442719232c5c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,876 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_04_01.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2021_04_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_04_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_configuration.py deleted file mode 100644 index 7f084d2540de1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_metadata.json deleted file mode 100644 index 61e2ad24f17ae..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2021-05-01", - "total_api_version_list": ["2021-05-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "metrics": "MetricsOperations", - "metric_definitions": "MetricDefinitionsOperations", - "operations": "Operations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_monitor_management_client.py deleted file mode 100644 index 448ef59afa732..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricDefinitionsOperations, MetricsOperations, Operations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2021_05_01.operations.MetricsOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2021_05_01.operations.MetricDefinitionsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.monitor.v2021_05_01.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_configuration.py deleted file mode 100644 index f210214ef4bfc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-05-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_monitor_management_client.py deleted file mode 100644 index 2a774106d5365..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricDefinitionsOperations, MetricsOperations, Operations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar metrics: MetricsOperations operations - :vartype metrics: azure.mgmt.monitor.v2021_05_01.aio.operations.MetricsOperations - :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: - azure.mgmt.monitor.v2021_05_01.aio.operations.MetricDefinitionsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.monitor.v2021_05_01.aio.operations.Operations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-05-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/__init__.py deleted file mode 100644 index ca1fe1731e6bf..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metrics_operations import MetricsOperations -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricsOperations", - "MetricDefinitionsOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_metric_definitions_operations.py deleted file mode 100644 index 3979d162f2f3e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,237 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_definitions_operations import build_list_at_subscription_scope_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01.aio.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_at_subscription_scope( - self, region: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionScopeMetricDefinition"]: - """Lists the metric definitions for the subscription. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionScopeMetricDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.SubscriptionScopeMetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - region=region, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list_at_subscription_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionScopeMetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_at_subscription_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricDefinitions" - } - - @distributed_trace - def list( - self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_metrics_operations.py deleted file mode 100644 index c91e57bd95dad..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_metrics_operations.py +++ /dev/null @@ -1,630 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metrics_operations import ( - build_list_at_subscription_scope_post_request, - build_list_at_subscription_scope_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01.aio.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list_at_subscription_scope( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.SubscriptionScopeMetricResponse] = kwargs.pop("cls", None) - - request = build_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - region=region, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - auto_adjust_timegrain=auto_adjust_timegrain, - validate_dimensions=validate_dimensions, - api_version=api_version, - template_url=self.list_at_subscription_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionScopeMetricResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_at_subscription_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics" - } - - @overload - async def list_at_subscription_scope_post( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - body: Optional[_models.SubscriptionScopeMetricsRequestBodyParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. Parameters can be specified on either query - params or the body. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :param body: Parameters serialized in the body. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricsRequestBodyParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def list_at_subscription_scope_post( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. Parameters can be specified on either query - params or the body. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :param body: Parameters serialized in the body. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def list_at_subscription_scope_post( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - body: Optional[Union[_models.SubscriptionScopeMetricsRequestBodyParameters, IO]] = None, - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. Parameters can be specified on either query - params or the body. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :param body: Parameters serialized in the body. Is either a - SubscriptionScopeMetricsRequestBodyParameters type or a IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricsRequestBodyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SubscriptionScopeMetricResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "SubscriptionScopeMetricsRequestBodyParameters") - else: - _json = None - - request = build_list_at_subscription_scope_post_request( - subscription_id=self._config.subscription_id, - region=region, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - auto_adjust_timegrain=auto_adjust_timegrain, - validate_dimensions=validate_dimensions, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.list_at_subscription_scope_post.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionScopeMetricResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_at_subscription_scope_post.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics" - } - - @distributed_trace_async - async def list( - self, - resource_uri: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any - ) -> _models.Response: - """**Lists the metric values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.ResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.Response - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.Response] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - auto_adjust_timegrain=auto_adjust_timegrain, - validate_dimensions=validate_dimensions, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Response", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_operations.py deleted file mode 100644 index 81c47663e4916..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_operations.py +++ /dev/null @@ -1,104 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01.aio.MonitorManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list(self, **kwargs: Any) -> _models.OperationListResult: - """Lists all of the available operations from Microsoft.Insights provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.OperationListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/__init__.py deleted file mode 100644 index 9e8662c0512fc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/__init__.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import DimensionProperties -from ._models_py3 import ErrorContract -from ._models_py3 import ErrorResponse -from ._models_py3 import LocalizableString -from ._models_py3 import LogSpecification -from ._models_py3 import MetadataValue -from ._models_py3 import Metric -from ._models_py3 import MetricAvailability -from ._models_py3 import MetricDefinition -from ._models_py3 import MetricDefinitionCollection -from ._models_py3 import MetricSpecification -from ._models_py3 import MetricValue -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Response -from ._models_py3 import ServiceSpecification -from ._models_py3 import SubscriptionScopeMetric -from ._models_py3 import SubscriptionScopeMetricDefinition -from ._models_py3 import SubscriptionScopeMetricDefinitionCollection -from ._models_py3 import SubscriptionScopeMetricResponse -from ._models_py3 import SubscriptionScopeMetricsRequestBodyParameters -from ._models_py3 import TimeSeriesElement - -from ._monitor_management_client_enums import AggregationType -from ._monitor_management_client_enums import MetricAggregationType -from ._monitor_management_client_enums import MetricClass -from ._monitor_management_client_enums import MetricResultType -from ._monitor_management_client_enums import MetricUnit -from ._monitor_management_client_enums import ResultType -from ._monitor_management_client_enums import Unit -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DimensionProperties", - "ErrorContract", - "ErrorResponse", - "LocalizableString", - "LogSpecification", - "MetadataValue", - "Metric", - "MetricAvailability", - "MetricDefinition", - "MetricDefinitionCollection", - "MetricSpecification", - "MetricValue", - "Operation", - "OperationDisplay", - "OperationListResult", - "Response", - "ServiceSpecification", - "SubscriptionScopeMetric", - "SubscriptionScopeMetricDefinition", - "SubscriptionScopeMetricDefinitionCollection", - "SubscriptionScopeMetricResponse", - "SubscriptionScopeMetricsRequestBodyParameters", - "TimeSeriesElement", - "AggregationType", - "MetricAggregationType", - "MetricClass", - "MetricResultType", - "MetricUnit", - "ResultType", - "Unit", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_models_py3.py deleted file mode 100644 index 11c8187396fcb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_models_py3.py +++ /dev/null @@ -1,1439 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class DimensionProperties(_serialization.Model): - """Type of operation: get, read, delete, etc. - - :ivar name: Name of dimension. - :vartype name: str - :ivar display_name: Display name of dimension. - :vartype display_name: str - :ivar to_be_exported_for_shoebox: Legacy usage, should not set. - :vartype to_be_exported_for_shoebox: bool - :ivar is_hidden: When set, the dimension is hidden from the customer, used in conjunction with - the defaultDimensionValues field below. - :vartype is_hidden: bool - :ivar default_dimension_values: Default dimension value to be sent down for the hidden - dimension during query. - :vartype default_dimension_values: JSON - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, - "is_hidden": {"key": "isHidden", "type": "bool"}, - "default_dimension_values": {"key": "defaultDimensionValues", "type": "object"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - to_be_exported_for_shoebox: Optional[bool] = None, - is_hidden: Optional[bool] = None, - default_dimension_values: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of dimension. - :paramtype name: str - :keyword display_name: Display name of dimension. - :paramtype display_name: str - :keyword to_be_exported_for_shoebox: Legacy usage, should not set. - :paramtype to_be_exported_for_shoebox: bool - :keyword is_hidden: When set, the dimension is hidden from the customer, used in conjunction - with the defaultDimensionValues field below. - :paramtype is_hidden: bool - :keyword default_dimension_values: Default dimension value to be sent down for the hidden - dimension during query. - :paramtype default_dimension_values: JSON - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.to_be_exported_for_shoebox = to_be_exported_for_shoebox - self.is_hidden = is_hidden - self.default_dimension_values = default_dimension_values - - -class ErrorContract(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2021_05_01.models.ErrorResponse - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponse"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2021_05_01.models.ErrorResponse - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class LocalizableString(_serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the invariant value. Required. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: the invariant value. Required. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class LogSpecification(_serialization.Model): - """Log specification of operation. - - :ivar name: Name of log specification. - :vartype name: str - :ivar display_name: Display name of log specification. - :vartype display_name: str - :ivar blob_duration: Blob duration of specification. - :vartype blob_duration: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "blob_duration": {"key": "blobDuration", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - blob_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of log specification. - :paramtype name: str - :keyword display_name: Display name of log specification. - :paramtype display_name: str - :keyword blob_duration: Blob duration of specification. - :paramtype blob_duration: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.blob_duration = blob_duration - - -class MetadataValue(_serialization.Model): - """Represents a metric metadata value. - - :ivar name: the name of the metadata. - :vartype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :ivar value: the value of the metadata. - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "LocalizableString"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__( - self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: the name of the metadata. - :paramtype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :keyword value: the value of the metadata. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class Metric(_serialization.Model): - """The result data of a query. - - All required parameters must be populated in order to send to Azure. - - :ivar id: the metric Id. Required. - :vartype id: str - :ivar type: the resource type of the metric resource. Required. - :vartype type: str - :ivar name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :vartype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar error_code: 'Success' or the error details on query failures for this metric. - :vartype error_code: str - :ivar error_message: Error message encountered querying this specific metric. - :vartype error_message: str - :ivar unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.Unit - :ivar timeseries: the time series returned when a data query is performed. Required. - :vartype timeseries: list[~azure.mgmt.monitor.v2021_05_01.models.TimeSeriesElement] - """ - - _validation = { - "id": {"required": True}, - "type": {"required": True}, - "name": {"required": True}, - "unit": {"required": True}, - "timeseries": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "timeseries": {"key": "timeseries", "type": "[TimeSeriesElement]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - type: str, - name: "_models.LocalizableString", - unit: Union[str, "_models.Unit"], - timeseries: List["_models.TimeSeriesElement"], - display_description: Optional[str] = None, - error_code: Optional[str] = None, - error_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: the metric Id. Required. - :paramtype id: str - :keyword type: the resource type of the metric resource. Required. - :paramtype type: str - :keyword name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :paramtype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword error_code: 'Success' or the error details on query failures for this metric. - :paramtype error_code: str - :keyword error_message: Error message encountered querying this specific metric. - :paramtype error_message: str - :keyword unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.Unit - :keyword timeseries: the time series returned when a data query is performed. Required. - :paramtype timeseries: list[~azure.mgmt.monitor.v2021_05_01.models.TimeSeriesElement] - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.name = name - self.display_description = display_description - self.error_code = error_code - self.error_message = error_message - self.unit = unit - self.timeseries = timeseries - - -class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the - retention period for that time grain. - - :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed - as a duration 'PT1M', 'P1D', etc. - :vartype time_grain: ~datetime.timedelta - :ivar retention: the retention period for the metric at the specified timegrain. Expressed as - a duration 'PT1M', 'P1D', etc. - :vartype retention: ~datetime.timedelta - """ - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "retention": {"key": "retention", "type": "duration"}, - } - - def __init__( - self, - *, - time_grain: Optional[datetime.timedelta] = None, - retention: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the time grain specifies the aggregation interval for the metric. - Expressed as a duration 'PT1M', 'P1D', etc. - :paramtype time_grain: ~datetime.timedelta - :keyword retention: the retention period for the metric at the specified timegrain. Expressed - as a duration 'PT1M', 'P1D', etc. - :paramtype retention: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.retention = retention - - -class MetricDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Metric definition class specifies the metadata for a metric. - - :ivar is_dimension_required: Flag to indicate whether the dimension is required. - :vartype is_dimension_required: bool - :ivar resource_id: the resource identifier of the resource that emitted the metric. - :vartype resource_id: str - :ivar namespace: the namespace the metric belongs to. - :vartype namespace: str - :ivar name: the name and the display name of the metric, i.e. it is a localizable string. - :vartype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar category: Custom category name for this metric. - :vartype category: str - :ivar metric_class: The class of the metric. Known values are: "Availability", "Transactions", - "Errors", "Latency", and "Saturation". - :vartype metric_class: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricClass - :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricUnit - :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :vartype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2021_05_01.models.AggregationType - :ivar supported_aggregation_types: the collection of what aggregation types are supported. - :vartype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2021_05_01.models.AggregationType] - :ivar metric_availabilities: the collection of what aggregation intervals are available to be - queried. - :vartype metric_availabilities: list[~azure.mgmt.monitor.v2021_05_01.models.MetricAvailability] - :ivar id: the resource identifier of the metric definition. - :vartype id: str - :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :vartype dimensions: list[~azure.mgmt.monitor.v2021_05_01.models.LocalizableString] - """ - - _attribute_map = { - "is_dimension_required": {"key": "isDimensionRequired", "type": "bool"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "namespace": {"key": "namespace", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "metric_class": {"key": "metricClass", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, - "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, - "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, - "id": {"key": "id", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[LocalizableString]"}, - } - - def __init__( - self, - *, - is_dimension_required: Optional[bool] = None, - resource_id: Optional[str] = None, - namespace: Optional[str] = None, - name: Optional["_models.LocalizableString"] = None, - display_description: Optional[str] = None, - category: Optional[str] = None, - metric_class: Optional[Union[str, "_models.MetricClass"]] = None, - unit: Optional[Union[str, "_models.MetricUnit"]] = None, - primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, - supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, - metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - dimensions: Optional[List["_models.LocalizableString"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_dimension_required: Flag to indicate whether the dimension is required. - :paramtype is_dimension_required: bool - :keyword resource_id: the resource identifier of the resource that emitted the metric. - :paramtype resource_id: str - :keyword namespace: the namespace the metric belongs to. - :paramtype namespace: str - :keyword name: the name and the display name of the metric, i.e. it is a localizable string. - :paramtype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword category: Custom category name for this metric. - :paramtype category: str - :keyword metric_class: The class of the metric. Known values are: "Availability", - "Transactions", "Errors", "Latency", and "Saturation". - :paramtype metric_class: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricClass - :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricUnit - :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :paramtype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2021_05_01.models.AggregationType - :keyword supported_aggregation_types: the collection of what aggregation types are supported. - :paramtype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2021_05_01.models.AggregationType] - :keyword metric_availabilities: the collection of what aggregation intervals are available to - be queried. - :paramtype metric_availabilities: - list[~azure.mgmt.monitor.v2021_05_01.models.MetricAvailability] - :keyword id: the resource identifier of the metric definition. - :paramtype id: str - :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :paramtype dimensions: list[~azure.mgmt.monitor.v2021_05_01.models.LocalizableString] - """ - super().__init__(**kwargs) - self.is_dimension_required = is_dimension_required - self.resource_id = resource_id - self.namespace = namespace - self.name = name - self.display_description = display_description - self.category = category - self.metric_class = metric_class - self.unit = unit - self.primary_aggregation_type = primary_aggregation_type - self.supported_aggregation_types = supported_aggregation_types - self.metric_availabilities = metric_availabilities - self.id = id - self.dimensions = dimensions - - -class MetricDefinitionCollection(_serialization.Model): - """Represents collection of metric definitions. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values for the metric definitions. Required. - :vartype value: list[~azure.mgmt.monitor.v2021_05_01.models.MetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, - } - - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: the values for the metric definitions. Required. - :paramtype value: list[~azure.mgmt.monitor.v2021_05_01.models.MetricDefinition] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Metric specification of operation. - - :ivar name: The name of the metric. - :vartype name: str - :ivar display_name: Display name of the metric. - :vartype display_name: str - :ivar display_description: Display description of the metric. - :vartype display_description: str - :ivar unit: The metric unit. Possible values include: - Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. - :vartype unit: str - :ivar aggregation_type: The default metric aggregation type. Possible values include: - Total,Average,Maximum,Minimum,Count. - :vartype aggregation_type: str - :ivar supported_aggregation_types: The supported aggregation types for the metrics. - :vartype supported_aggregation_types: list[str] - :ivar supported_time_grain_types: The supported time grain types for the metrics. - :vartype supported_time_grain_types: list[str] - :ivar availabilities: The supported time grain types for the metrics. - :vartype availabilities: list[str] - :ivar lock_aggregation_type: The metric lock aggregation type. - :vartype lock_aggregation_type: str - :ivar category: Category or type of metric. - :vartype category: str - :ivar dimensions: The dimensions of metric. - :vartype dimensions: list[~azure.mgmt.monitor.v2021_05_01.models.DimensionProperties] - :ivar fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. - :vartype fill_gap_with_zero: bool - :ivar internal_metric_name: The internal metric name. - :vartype internal_metric_name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "aggregation_type": {"key": "aggregationType", "type": "str"}, - "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, - "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, - "availabilities": {"key": "availabilities", "type": "[str]"}, - "lock_aggregation_type": {"key": "lockAggregationType", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[DimensionProperties]"}, - "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, - "internal_metric_name": {"key": "internalMetricName", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - display_description: Optional[str] = None, - unit: Optional[str] = None, - aggregation_type: Optional[str] = None, - supported_aggregation_types: Optional[List[str]] = None, - supported_time_grain_types: Optional[List[str]] = None, - availabilities: Optional[List[str]] = None, - lock_aggregation_type: Optional[str] = None, - category: Optional[str] = None, - dimensions: Optional[List["_models.DimensionProperties"]] = None, - fill_gap_with_zero: Optional[bool] = None, - internal_metric_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the metric. - :paramtype name: str - :keyword display_name: Display name of the metric. - :paramtype display_name: str - :keyword display_description: Display description of the metric. - :paramtype display_description: str - :keyword unit: The metric unit. Possible values include: - Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. - :paramtype unit: str - :keyword aggregation_type: The default metric aggregation type. Possible values include: - Total,Average,Maximum,Minimum,Count. - :paramtype aggregation_type: str - :keyword supported_aggregation_types: The supported aggregation types for the metrics. - :paramtype supported_aggregation_types: list[str] - :keyword supported_time_grain_types: The supported time grain types for the metrics. - :paramtype supported_time_grain_types: list[str] - :keyword availabilities: The supported time grain types for the metrics. - :paramtype availabilities: list[str] - :keyword lock_aggregation_type: The metric lock aggregation type. - :paramtype lock_aggregation_type: str - :keyword category: Category or type of metric. - :paramtype category: str - :keyword dimensions: The dimensions of metric. - :paramtype dimensions: list[~azure.mgmt.monitor.v2021_05_01.models.DimensionProperties] - :keyword fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. - :paramtype fill_gap_with_zero: bool - :keyword internal_metric_name: The internal metric name. - :paramtype internal_metric_name: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.display_description = display_description - self.unit = unit - self.aggregation_type = aggregation_type - self.supported_aggregation_types = supported_aggregation_types - self.supported_time_grain_types = supported_time_grain_types - self.availabilities = availabilities - self.lock_aggregation_type = lock_aggregation_type - self.category = category - self.dimensions = dimensions - self.fill_gap_with_zero = fill_gap_with_zero - self.internal_metric_name = internal_metric_name - - -class MetricValue(_serialization.Model): - """Represents a metric value. - - All required parameters must be populated in order to send to Azure. - - :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :vartype time_stamp: ~datetime.datetime - :ivar average: the average value in the time range. - :vartype average: float - :ivar minimum: the least value in the time range. - :vartype minimum: float - :ivar maximum: the greatest value in the time range. - :vartype maximum: float - :ivar total: the sum of all of the values in the time range. - :vartype total: float - :ivar count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :vartype count: float - """ - - _validation = { - "time_stamp": {"required": True}, - } - - _attribute_map = { - "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, - "average": {"key": "average", "type": "float"}, - "minimum": {"key": "minimum", "type": "float"}, - "maximum": {"key": "maximum", "type": "float"}, - "total": {"key": "total", "type": "float"}, - "count": {"key": "count", "type": "float"}, - } - - def __init__( - self, - *, - time_stamp: datetime.datetime, - average: Optional[float] = None, - minimum: Optional[float] = None, - maximum: Optional[float] = None, - total: Optional[float] = None, - count: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :paramtype time_stamp: ~datetime.datetime - :keyword average: the average value in the time range. - :paramtype average: float - :keyword minimum: the least value in the time range. - :paramtype minimum: float - :keyword maximum: the greatest value in the time range. - :paramtype maximum: float - :keyword total: the sum of all of the values in the time range. - :paramtype total: float - :keyword count: the number of samples in the time range. Can be used to determine the number of - values that contributed to the average value. - :paramtype count: float - """ - super().__init__(**kwargs) - self.time_stamp = time_stamp - self.average = average - self.minimum = minimum - self.maximum = maximum - self.total = total - self.count = count - - -class Operation(_serialization.Model): - """Microsoft Insights API operation definition. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar is_data_action: Property to specify whether the action is a data action. - :vartype is_data_action: bool - :ivar display: Display metadata associated with the operation. - :vartype display: ~azure.mgmt.monitor.v2021_05_01.models.OperationDisplay - :ivar service_specification: One property of operation, include metric specifications. - :vartype service_specification: ~azure.mgmt.monitor.v2021_05_01.models.ServiceSpecification - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - service_specification: Optional["_models.ServiceSpecification"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Operation name: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword is_data_action: Property to specify whether the action is a data action. - :paramtype is_data_action: bool - :keyword display: Display metadata associated with the operation. - :paramtype display: ~azure.mgmt.monitor.v2021_05_01.models.OperationDisplay - :keyword service_specification: One property of operation, include metric specifications. - :paramtype service_specification: ~azure.mgmt.monitor.v2021_05_01.models.ServiceSpecification - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.service_specification = service_specification - - -class OperationDisplay(_serialization.Model): - """Display metadata associated with the operation. - - :ivar publisher: The publisher of this operation. - :vartype publisher: str - :ivar provider: Service provider: Microsoft.Insights. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - :ivar description: The description of the operation. - :vartype description: str - """ - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - publisher: Optional[str] = None, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword publisher: The publisher of this operation. - :paramtype publisher: str - :keyword provider: Service provider: Microsoft.Insights. - :paramtype provider: str - :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :paramtype resource: str - :keyword operation: Operation type: Read, write, delete, etc. - :paramtype operation: str - :keyword description: The description of the operation. - :paramtype description: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationListResult(_serialization.Model): - """Result of the request to list Microsoft.Insights operations. It contains a list of operations - and a URL link to get the next set of results. - - :ivar value: List of operations supported by the Microsoft.Insights provider. - :vartype value: list[~azure.mgmt.monitor.v2021_05_01.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of operations supported by the Microsoft.Insights provider. - :paramtype value: list[~azure.mgmt.monitor.v2021_05_01.models.Operation] - :keyword next_link: URL to get the next set of operation list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Response(_serialization.Model): - """The response to a metrics query. - - All required parameters must be populated in order to send to Azure. - - :ivar cost: The integer value representing the relative cost of the query. - :vartype cost: int - :ivar timespan: 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. Required. - :vartype timespan: str - :ivar interval: 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. - :vartype interval: ~datetime.timedelta - :ivar namespace: The namespace of the metrics being queried. - :vartype namespace: str - :ivar resourceregion: The region of the resource being queried for metrics. - :vartype resourceregion: str - :ivar value: the value of the collection. Required. - :vartype value: list[~azure.mgmt.monitor.v2021_05_01.models.Metric] - """ - - _validation = { - "cost": {"minimum": 0}, - "timespan": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "cost": {"key": "cost", "type": "int"}, - "timespan": {"key": "timespan", "type": "str"}, - "interval": {"key": "interval", "type": "duration"}, - "namespace": {"key": "namespace", "type": "str"}, - "resourceregion": {"key": "resourceregion", "type": "str"}, - "value": {"key": "value", "type": "[Metric]"}, - } - - def __init__( - self, - *, - timespan: str, - value: List["_models.Metric"], - cost: Optional[int] = None, - interval: Optional[datetime.timedelta] = None, - namespace: Optional[str] = None, - resourceregion: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword cost: The integer value representing the relative cost of the query. - :paramtype cost: int - :keyword timespan: 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. Required. - :paramtype timespan: str - :keyword interval: 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. - :paramtype interval: ~datetime.timedelta - :keyword namespace: The namespace of the metrics being queried. - :paramtype namespace: str - :keyword resourceregion: The region of the resource being queried for metrics. - :paramtype resourceregion: str - :keyword value: the value of the collection. Required. - :paramtype value: list[~azure.mgmt.monitor.v2021_05_01.models.Metric] - """ - super().__init__(**kwargs) - self.cost = cost - self.timespan = timespan - self.interval = interval - self.namespace = namespace - self.resourceregion = resourceregion - self.value = value - - -class ServiceSpecification(_serialization.Model): - """One property of operation, include log specifications. - - :ivar log_specifications: Log specifications of operation. - :vartype log_specifications: list[~azure.mgmt.monitor.v2021_05_01.models.LogSpecification] - :ivar metric_specifications: Metric specifications of operation. - :vartype metric_specifications: - list[~azure.mgmt.monitor.v2021_05_01.models.MetricSpecification] - :ivar legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do - not use. - :vartype legacy_metric_specifications: JSON - """ - - _attribute_map = { - "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, - "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, - "legacy_metric_specifications": {"key": "legacyMetricSpecifications", "type": "object"}, - } - - def __init__( - self, - *, - log_specifications: Optional[List["_models.LogSpecification"]] = None, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - legacy_metric_specifications: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_specifications: Log specifications of operation. - :paramtype log_specifications: list[~azure.mgmt.monitor.v2021_05_01.models.LogSpecification] - :keyword metric_specifications: Metric specifications of operation. - :paramtype metric_specifications: - list[~azure.mgmt.monitor.v2021_05_01.models.MetricSpecification] - :keyword legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, - do not use. - :paramtype legacy_metric_specifications: JSON - """ - super().__init__(**kwargs) - self.log_specifications = log_specifications - self.metric_specifications = metric_specifications - self.legacy_metric_specifications = legacy_metric_specifications - - -class SubscriptionScopeMetric(_serialization.Model): - """The result data of a query. - - All required parameters must be populated in order to send to Azure. - - :ivar id: the metric Id. Required. - :vartype id: str - :ivar type: the resource type of the metric resource. Required. - :vartype type: str - :ivar name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :vartype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar error_code: 'Success' or the error details on query failures for this metric. - :vartype error_code: str - :ivar error_message: Error message encountered querying this specific metric. - :vartype error_message: str - :ivar unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricUnit - :ivar timeseries: the time series returned when a data query is performed. Required. - :vartype timeseries: list[~azure.mgmt.monitor.v2021_05_01.models.TimeSeriesElement] - """ - - _validation = { - "id": {"required": True}, - "type": {"required": True}, - "name": {"required": True}, - "unit": {"required": True}, - "timeseries": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "timeseries": {"key": "timeseries", "type": "[TimeSeriesElement]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - type: str, - name: "_models.LocalizableString", - unit: Union[str, "_models.MetricUnit"], - timeseries: List["_models.TimeSeriesElement"], - display_description: Optional[str] = None, - error_code: Optional[str] = None, - error_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: the metric Id. Required. - :paramtype id: str - :keyword type: the resource type of the metric resource. Required. - :paramtype type: str - :keyword name: the name and the display name of the metric, i.e. it is localizable string. - Required. - :paramtype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword error_code: 'Success' or the error details on query failures for this metric. - :paramtype error_code: str - :keyword error_message: Error message encountered querying this specific metric. - :paramtype error_message: str - :keyword unit: The unit of the metric. Required. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricUnit - :keyword timeseries: the time series returned when a data query is performed. Required. - :paramtype timeseries: list[~azure.mgmt.monitor.v2021_05_01.models.TimeSeriesElement] - """ - super().__init__(**kwargs) - self.id = id - self.type = type - self.name = name - self.display_description = display_description - self.error_code = error_code - self.error_message = error_message - self.unit = unit - self.timeseries = timeseries - - -class SubscriptionScopeMetricDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Metric definition class specifies the metadata for a metric. - - :ivar is_dimension_required: Flag to indicate whether the dimension is required. - :vartype is_dimension_required: bool - :ivar resource_id: the resource identifier of the resource that emitted the metric. - :vartype resource_id: str - :ivar namespace: the namespace the metric belongs to. - :vartype namespace: str - :ivar name: the name and the display name of the metric, i.e. it is a localizable string. - :vartype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :ivar display_description: Detailed description of this metric. - :vartype display_description: str - :ivar category: Custom category name for this metric. - :vartype category: str - :ivar metric_class: The class of the metric. Known values are: "Availability", "Transactions", - "Errors", "Latency", and "Saturation". - :vartype metric_class: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricClass - :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :vartype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricUnit - :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :vartype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2021_05_01.models.MetricAggregationType - :ivar supported_aggregation_types: the collection of what aggregation types are supported. - :vartype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2021_05_01.models.MetricAggregationType] - :ivar metric_availabilities: the collection of what aggregation intervals are available to be - queried. - :vartype metric_availabilities: list[~azure.mgmt.monitor.v2021_05_01.models.MetricAvailability] - :ivar id: the resource identifier of the metric definition. - :vartype id: str - :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :vartype dimensions: list[~azure.mgmt.monitor.v2021_05_01.models.LocalizableString] - """ - - _attribute_map = { - "is_dimension_required": {"key": "isDimensionRequired", "type": "bool"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "namespace": {"key": "namespace", "type": "str"}, - "name": {"key": "name", "type": "LocalizableString"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "metric_class": {"key": "metricClass", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, - "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, - "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, - "id": {"key": "id", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[LocalizableString]"}, - } - - def __init__( - self, - *, - is_dimension_required: Optional[bool] = None, - resource_id: Optional[str] = None, - namespace: Optional[str] = None, - name: Optional["_models.LocalizableString"] = None, - display_description: Optional[str] = None, - category: Optional[str] = None, - metric_class: Optional[Union[str, "_models.MetricClass"]] = None, - unit: Optional[Union[str, "_models.MetricUnit"]] = None, - primary_aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, - supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, - metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - dimensions: Optional[List["_models.LocalizableString"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_dimension_required: Flag to indicate whether the dimension is required. - :paramtype is_dimension_required: bool - :keyword resource_id: the resource identifier of the resource that emitted the metric. - :paramtype resource_id: str - :keyword namespace: the namespace the metric belongs to. - :paramtype namespace: str - :keyword name: the name and the display name of the metric, i.e. it is a localizable string. - :paramtype name: ~azure.mgmt.monitor.v2021_05_01.models.LocalizableString - :keyword display_description: Detailed description of this metric. - :paramtype display_description: str - :keyword category: Custom category name for this metric. - :paramtype category: str - :keyword metric_class: The class of the metric. Known values are: "Availability", - "Transactions", "Errors", "Latency", and "Saturation". - :paramtype metric_class: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricClass - :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", - "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", - "Cores", "MilliCores", "NanoCores", and "BitsPerSecond". - :paramtype unit: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricUnit - :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and - "Total". - :paramtype primary_aggregation_type: str or - ~azure.mgmt.monitor.v2021_05_01.models.MetricAggregationType - :keyword supported_aggregation_types: the collection of what aggregation types are supported. - :paramtype supported_aggregation_types: list[str or - ~azure.mgmt.monitor.v2021_05_01.models.MetricAggregationType] - :keyword metric_availabilities: the collection of what aggregation intervals are available to - be queried. - :paramtype metric_availabilities: - list[~azure.mgmt.monitor.v2021_05_01.models.MetricAvailability] - :keyword id: the resource identifier of the metric definition. - :paramtype id: str - :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable - string. - :paramtype dimensions: list[~azure.mgmt.monitor.v2021_05_01.models.LocalizableString] - """ - super().__init__(**kwargs) - self.is_dimension_required = is_dimension_required - self.resource_id = resource_id - self.namespace = namespace - self.name = name - self.display_description = display_description - self.category = category - self.metric_class = metric_class - self.unit = unit - self.primary_aggregation_type = primary_aggregation_type - self.supported_aggregation_types = supported_aggregation_types - self.metric_availabilities = metric_availabilities - self.id = id - self.dimensions = dimensions - - -class SubscriptionScopeMetricDefinitionCollection(_serialization.Model): - """Represents collection of metric definitions. - - All required parameters must be populated in order to send to Azure. - - :ivar value: The values for the metric definitions. Required. - :vartype value: list[~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SubscriptionScopeMetricDefinition]"}, - } - - def __init__(self, *, value: List["_models.SubscriptionScopeMetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: The values for the metric definitions. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricDefinition] - """ - super().__init__(**kwargs) - self.value = value - - -class SubscriptionScopeMetricResponse(_serialization.Model): - """The response to a subscription scope metrics query. - - All required parameters must be populated in order to send to Azure. - - :ivar cost: The integer value representing the relative cost of the query. - :vartype cost: int - :ivar timespan: 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. Required. - :vartype timespan: str - :ivar interval: 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. - :vartype interval: ~datetime.timedelta - :ivar namespace: The namespace of the metrics being queried. - :vartype namespace: str - :ivar resourceregion: The region of the resource being queried for metrics. - :vartype resourceregion: str - :ivar value: the value of the collection. Required. - :vartype value: list[~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetric] - """ - - _validation = { - "cost": {"minimum": 0}, - "timespan": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "cost": {"key": "cost", "type": "int"}, - "timespan": {"key": "timespan", "type": "str"}, - "interval": {"key": "interval", "type": "duration"}, - "namespace": {"key": "namespace", "type": "str"}, - "resourceregion": {"key": "resourceregion", "type": "str"}, - "value": {"key": "value", "type": "[SubscriptionScopeMetric]"}, - } - - def __init__( - self, - *, - timespan: str, - value: List["_models.SubscriptionScopeMetric"], - cost: Optional[int] = None, - interval: Optional[datetime.timedelta] = None, - namespace: Optional[str] = None, - resourceregion: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword cost: The integer value representing the relative cost of the query. - :paramtype cost: int - :keyword timespan: 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. Required. - :paramtype timespan: str - :keyword interval: 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. - :paramtype interval: ~datetime.timedelta - :keyword namespace: The namespace of the metrics being queried. - :paramtype namespace: str - :keyword resourceregion: The region of the resource being queried for metrics. - :paramtype resourceregion: str - :keyword value: the value of the collection. Required. - :paramtype value: list[~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetric] - """ - super().__init__(**kwargs) - self.cost = cost - self.timespan = timespan - self.interval = interval - self.namespace = namespace - self.resourceregion = resourceregion - self.value = value - - -class SubscriptionScopeMetricsRequestBodyParameters( - _serialization.Model -): # pylint: disable=too-many-instance-attributes - """Query parameters can also be specified in the body, specifying the same parameter in both the - body and query parameters will result in an error. - - :ivar timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :vartype timespan: ~datetime.time - :ivar interval: The interval (i.e. timegrain) of the query. - :vartype interval: ~datetime.timedelta - :ivar metric_names: The names of the metrics (comma separated) to retrieve. - :vartype metric_names: str - :ivar aggregation: The list of aggregation types (comma separated) to retrieve. - :vartype aggregation: str - :ivar filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. - :vartype filter: str - :ivar top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. - :vartype top: int - :ivar order_by: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. - :vartype order_by: str - :ivar roll_up_by: Dimension name(s) to rollup results by. For example if you only want to see - metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see - separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle - and Tacoma rolled up into one timeseries. - :vartype roll_up_by: str - :ivar result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". - :vartype result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :ivar metric_namespace: Metric namespace where the metrics you want reside. - :vartype metric_namespace: str - :ivar auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. - :vartype auto_adjust_timegrain: bool - :ivar validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. - :vartype validate_dimensions: bool - """ - - _attribute_map = { - "timespan": {"key": "timespan", "type": "time"}, - "interval": {"key": "interval", "type": "duration"}, - "metric_names": {"key": "metricNames", "type": "str"}, - "aggregation": {"key": "aggregation", "type": "str"}, - "filter": {"key": "filter", "type": "str"}, - "top": {"key": "top", "type": "int"}, - "order_by": {"key": "orderBy", "type": "str"}, - "roll_up_by": {"key": "rollUpBy", "type": "str"}, - "result_type": {"key": "resultType", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "auto_adjust_timegrain": {"key": "autoAdjustTimegrain", "type": "bool"}, - "validate_dimensions": {"key": "validateDimensions", "type": "bool"}, - } - - def __init__( - self, - *, - timespan: Optional[datetime.time] = None, - interval: Optional[datetime.timedelta] = None, - metric_names: Optional[str] = None, - aggregation: Optional[str] = None, - filter: Optional[str] = None, # pylint: disable=redefined-builtin - top: Optional[int] = None, - order_by: Optional[str] = None, - roll_up_by: Optional[str] = None, - result_type: Optional[Union[str, "_models.MetricResultType"]] = None, - metric_namespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :paramtype timespan: ~datetime.time - :keyword interval: The interval (i.e. timegrain) of the query. - :paramtype interval: ~datetime.timedelta - :keyword metric_names: The names of the metrics (comma separated) to retrieve. - :paramtype metric_names: str - :keyword aggregation: The list of aggregation types (comma separated) to retrieve. - :paramtype aggregation: str - :keyword filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. - :paramtype filter: str - :keyword top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. - :paramtype top: int - :keyword order_by: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. - :paramtype order_by: str - :keyword roll_up_by: Dimension name(s) to rollup results by. For example if you only want to - see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see - separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle - and Tacoma rolled up into one timeseries. - :paramtype roll_up_by: str - :keyword result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". - :paramtype result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :keyword metric_namespace: Metric namespace where the metrics you want reside. - :paramtype metric_namespace: str - :keyword auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. - :paramtype auto_adjust_timegrain: bool - :keyword validate_dimensions: When set to false, invalid filter parameter values will be - ignored. When set to true, an error is returned for invalid filter parameters. Defaults to - true. - :paramtype validate_dimensions: bool - """ - super().__init__(**kwargs) - self.timespan = timespan - self.interval = interval - self.metric_names = metric_names - self.aggregation = aggregation - self.filter = filter - self.top = top - self.order_by = order_by - self.roll_up_by = roll_up_by - self.result_type = result_type - self.metric_namespace = metric_namespace - self.auto_adjust_timegrain = auto_adjust_timegrain - self.validate_dimensions = validate_dimensions - - -class TimeSeriesElement(_serialization.Model): - """A time series result type. The discriminator value is always TimeSeries in this case. - - :ivar metadatavalues: the metadata values returned if $filter was specified in the call. - :vartype metadatavalues: list[~azure.mgmt.monitor.v2021_05_01.models.MetadataValue] - :ivar data: An array of data points representing the metric values. This is only returned if a - result type of data is specified. - :vartype data: list[~azure.mgmt.monitor.v2021_05_01.models.MetricValue] - """ - - _attribute_map = { - "metadatavalues": {"key": "metadatavalues", "type": "[MetadataValue]"}, - "data": {"key": "data", "type": "[MetricValue]"}, - } - - def __init__( - self, - *, - metadatavalues: Optional[List["_models.MetadataValue"]] = None, - data: Optional[List["_models.MetricValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword metadatavalues: the metadata values returned if $filter was specified in the call. - :paramtype metadatavalues: list[~azure.mgmt.monitor.v2021_05_01.models.MetadataValue] - :keyword data: An array of data points representing the metric values. This is only returned - if a result type of data is specified. - :paramtype data: list[~azure.mgmt.monitor.v2021_05_01.models.MetricValue] - """ - super().__init__(**kwargs) - self.metadatavalues = metadatavalues - self.data = data diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 192dfa394d441..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the aggregation type of the metric.""" - - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - - -class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the aggregation type of the metric.""" - - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - - -class MetricClass(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The class of the metric.""" - - AVAILABILITY = "Availability" - TRANSACTIONS = "Transactions" - ERRORS = "Errors" - LATENCY = "Latency" - SATURATION = "Saturation" - - -class MetricResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Reduces the set of data collected. The syntax allowed depends on the operation. See the - operation's description for details. - """ - - DATA = "Data" - METADATA = "Metadata" - - -class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - PERCENT = "Percent" - MILLI_SECONDS = "MilliSeconds" - BYTE_SECONDS = "ByteSeconds" - UNSPECIFIED = "Unspecified" - CORES = "Cores" - MILLI_CORES = "MilliCores" - NANO_CORES = "NanoCores" - BITS_PER_SECOND = "BitsPerSecond" - - -class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ResultType.""" - - DATA = "Data" - METADATA = "Metadata" - - -class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - PERCENT = "Percent" - MILLI_SECONDS = "MilliSeconds" - BYTE_SECONDS = "ByteSeconds" - UNSPECIFIED = "Unspecified" - CORES = "Cores" - MILLI_CORES = "MilliCores" - NANO_CORES = "NanoCores" - BITS_PER_SECOND = "BitsPerSecond" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/__init__.py deleted file mode 100644 index ca1fe1731e6bf..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._metrics_operations import MetricsOperations -from ._metric_definitions_operations import MetricDefinitionsOperations -from ._operations import Operations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MetricsOperations", - "MetricDefinitionsOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_metric_definitions_operations.py deleted file mode 100644 index 84e1f46e17942..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_metric_definitions_operations.py +++ /dev/null @@ -1,294 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_at_subscription_scope_request( - subscription_id: str, *, region: str, metricnamespace: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricDefinitions") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["region"] = _SERIALIZER.query("region", region, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_uri: str, *, metricnamespace: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01.MonitorManagementClient`'s - :attr:`metric_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_at_subscription_scope( - self, region: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionScopeMetricDefinition"]: - """Lists the metric definitions for the subscription. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionScopeMetricDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.SubscriptionScopeMetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - region=region, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list_at_subscription_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionScopeMetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_at_subscription_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricDefinitions" - } - - @distributed_trace - def list( - self, resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricDefinition"]: - """Lists the metric definitions for the resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - metricnamespace=metricnamespace, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_metrics_operations.py deleted file mode 100644 index 939cc1fa73f01..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_metrics_operations.py +++ /dev/null @@ -1,819 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_at_subscription_scope_request( - subscription_id: str, - *, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["region"] = _SERIALIZER.query("region", region, "str") - if timespan is not None: - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - if metricnames is not None: - _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") - if aggregation is not None: - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["orderby"] = _SERIALIZER.query("orderby", orderby, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if result_type is not None: - _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - if auto_adjust_timegrain is not None: - _params["AutoAdjustTimegrain"] = _SERIALIZER.query("auto_adjust_timegrain", auto_adjust_timegrain, "bool") - if validate_dimensions is not None: - _params["ValidateDimensions"] = _SERIALIZER.query("validate_dimensions", validate_dimensions, "bool") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_at_subscription_scope_post_request( # pylint: disable=name-too-long - subscription_id: str, - *, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["region"] = _SERIALIZER.query("region", region, "str") - if timespan is not None: - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - if metricnames is not None: - _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") - if aggregation is not None: - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["orderby"] = _SERIALIZER.query("orderby", orderby, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if result_type is not None: - _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - if auto_adjust_timegrain is not None: - _params["AutoAdjustTimegrain"] = _SERIALIZER.query("auto_adjust_timegrain", auto_adjust_timegrain, "bool") - if validate_dimensions is not None: - _params["ValidateDimensions"] = _SERIALIZER.query("validate_dimensions", validate_dimensions, "bool") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - resource_uri: str, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metrics") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if timespan is not None: - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - if metricnames is not None: - _params["metricnames"] = _SERIALIZER.query("metricnames", metricnames, "str") - if aggregation is not None: - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if orderby is not None: - _params["orderby"] = _SERIALIZER.query("orderby", orderby, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if result_type is not None: - _params["resultType"] = _SERIALIZER.query("result_type", result_type, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if metricnamespace is not None: - _params["metricnamespace"] = _SERIALIZER.query("metricnamespace", metricnamespace, "str") - if auto_adjust_timegrain is not None: - _params["AutoAdjustTimegrain"] = _SERIALIZER.query("auto_adjust_timegrain", auto_adjust_timegrain, "bool") - if validate_dimensions is not None: - _params["ValidateDimensions"] = _SERIALIZER.query("validate_dimensions", validate_dimensions, "bool") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01.MonitorManagementClient`'s - :attr:`metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_at_subscription_scope( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.SubscriptionScopeMetricResponse] = kwargs.pop("cls", None) - - request = build_list_at_subscription_scope_request( - subscription_id=self._config.subscription_id, - region=region, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - auto_adjust_timegrain=auto_adjust_timegrain, - validate_dimensions=validate_dimensions, - api_version=api_version, - template_url=self.list_at_subscription_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionScopeMetricResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_at_subscription_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics" - } - - @overload - def list_at_subscription_scope_post( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - body: Optional[_models.SubscriptionScopeMetricsRequestBodyParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. Parameters can be specified on either query - params or the body. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :param body: Parameters serialized in the body. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricsRequestBodyParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def list_at_subscription_scope_post( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. Parameters can be specified on either query - params or the body. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :param body: Parameters serialized in the body. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def list_at_subscription_scope_post( - self, - region: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.MetricResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - body: Optional[Union[_models.SubscriptionScopeMetricsRequestBodyParameters, IO]] = None, - **kwargs: Any - ) -> _models.SubscriptionScopeMetricResponse: - """**Lists the metric data for a subscription**. Parameters can be specified on either query - params or the body. - - :param region: The region where the metrics you want reside. Required. - :type region: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.MetricResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :param body: Parameters serialized in the body. Is either a - SubscriptionScopeMetricsRequestBodyParameters type or a IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricsRequestBodyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionScopeMetricResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.SubscriptionScopeMetricResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SubscriptionScopeMetricResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "SubscriptionScopeMetricsRequestBodyParameters") - else: - _json = None - - request = build_list_at_subscription_scope_post_request( - subscription_id=self._config.subscription_id, - region=region, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - auto_adjust_timegrain=auto_adjust_timegrain, - validate_dimensions=validate_dimensions, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.list_at_subscription_scope_post.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionScopeMetricResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_at_subscription_scope_post.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics" - } - - @distributed_trace - def list( - self, - resource_uri: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metricnames: Optional[str] = None, - aggregation: Optional[str] = None, - top: Optional[int] = None, - orderby: Optional[str] = None, - filter: Optional[str] = None, - result_type: Optional[Union[str, _models.ResultType]] = None, - metricnamespace: Optional[str] = None, - auto_adjust_timegrain: Optional[bool] = None, - validate_dimensions: Optional[bool] = None, - **kwargs: Any - ) -> _models.Response: - """**Lists the metric values for a resource**. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Default value is None. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Default value is None. - :type interval: ~datetime.timedelta - :param metricnames: The names of the metrics (comma separated) to retrieve. Default value is - None. - :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value - is None. - :type aggregation: str - :param top: The maximum number of records to retrieve. - Valid only if $filter is specified. - Defaults to 10. Default value is None. - :type top: int - :param orderby: The aggregation to use for sorting results and the direction of the sort. - Only one order can be specified. - Examples: sum asc. Default value is None. - :type orderby: str - :param filter: The **$filter** is used to reduce the set of metric data - returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- - Return all time series of C where A = a1 and B = b1 or b2:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**\ :code:`
`- Invalid variant::code:`
`\ **$filter=A - eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**\ :code:`
`This is invalid because the - logical or operator cannot separate two different metadata names.:code:`
`- Return all time - series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq - ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. - :type filter: str - :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. Known values are: "Data" and - "Metadata". Default value is None. - :type result_type: str or ~azure.mgmt.monitor.v2021_05_01.models.ResultType - :param metricnamespace: Metric namespace where the metrics you want reside. Default value is - None. - :type metricnamespace: str - :param auto_adjust_timegrain: When set to true, if the timespan passed in is not supported by - this metric, the API will return the result using the closest supported timespan. When set to - false, an error is returned for invalid timespan parameters. Defaults to false. Default value - is None. - :type auto_adjust_timegrain: bool - :param validate_dimensions: When set to false, invalid filter parameter values will be ignored. - When set to true, an error is returned for invalid filter parameters. Defaults to true. Default - value is None. - :type validate_dimensions: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Response or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.Response - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.Response] = kwargs.pop("cls", None) - - request = build_list_request( - resource_uri=resource_uri, - timespan=timespan, - interval=interval, - metricnames=metricnames, - aggregation=aggregation, - top=top, - orderby=orderby, - filter=filter, - result_type=result_type, - metricnamespace=metricnamespace, - auto_adjust_timegrain=auto_adjust_timegrain, - validate_dimensions=validate_dimensions, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Response", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_operations.py deleted file mode 100644 index 256cf97311e87..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_operations.py +++ /dev/null @@ -1,126 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01.MonitorManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> _models.OperationListResult: - """Lists all of the available operations from Microsoft.Insights provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01.models.OperationListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py deleted file mode 100644 index 225ab16920795..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json deleted file mode 100644 index f2b273c6bf72c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2021-05-01-preview", - "total_api_version_list": ["2021-05-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "autoscale_settings": "AutoscaleSettingsOperations", - "predictive_metric": "PredictiveMetricOperations", - "diagnostic_settings": "DiagnosticSettingsOperations", - "diagnostic_settings_category": "DiagnosticSettingsCategoryOperations", - "management_group_diagnostic_settings": "ManagementGroupDiagnosticSettingsOperations", - "subscription_diagnostic_settings": "SubscriptionDiagnosticSettingsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py deleted file mode 100644 index 4330b407ed8ce..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - AutoscaleSettingsOperations, - DiagnosticSettingsCategoryOperations, - DiagnosticSettingsOperations, - ManagementGroupDiagnosticSettingsOperations, - PredictiveMetricOperations, - SubscriptionDiagnosticSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: - azure.mgmt.monitor.v2021_05_01_preview.operations.AutoscaleSettingsOperations - :ivar predictive_metric: PredictiveMetricOperations operations - :vartype predictive_metric: - azure.mgmt.monitor.v2021_05_01_preview.operations.PredictiveMetricOperations - :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: - azure.mgmt.monitor.v2021_05_01_preview.operations.DiagnosticSettingsOperations - :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: - azure.mgmt.monitor.v2021_05_01_preview.operations.DiagnosticSettingsCategoryOperations - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations - operations - :vartype management_group_diagnostic_settings: - azure.mgmt.monitor.v2021_05_01_preview.operations.ManagementGroupDiagnosticSettingsOperations - :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: - azure.mgmt.monitor.v2021_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.predictive_metric = PredictiveMetricOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py deleted file mode 100644 index 06c4726413bfd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 13974f530e37c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - AutoscaleSettingsOperations, - DiagnosticSettingsCategoryOperations, - DiagnosticSettingsOperations, - ManagementGroupDiagnosticSettingsOperations, - PredictiveMetricOperations, - SubscriptionDiagnosticSettingsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: - azure.mgmt.monitor.v2021_05_01_preview.aio.operations.AutoscaleSettingsOperations - :ivar predictive_metric: PredictiveMetricOperations operations - :vartype predictive_metric: - azure.mgmt.monitor.v2021_05_01_preview.aio.operations.PredictiveMetricOperations - :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: - azure.mgmt.monitor.v2021_05_01_preview.aio.operations.DiagnosticSettingsOperations - :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: - azure.mgmt.monitor.v2021_05_01_preview.aio.operations.DiagnosticSettingsCategoryOperations - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations - operations - :vartype management_group_diagnostic_settings: - azure.mgmt.monitor.v2021_05_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations - :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: - azure.mgmt.monitor.v2021_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.predictive_metric = PredictiveMetricOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index 526d8450f6ce4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._autoscale_settings_operations import AutoscaleSettingsOperations -from ._predictive_metric_operations import PredictiveMetricOperations -from ._diagnostic_settings_operations import DiagnosticSettingsOperations -from ._diagnostic_settings_category_operations import DiagnosticSettingsCategoryOperations -from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations -from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoscaleSettingsOperations", - "PredictiveMetricOperations", - "DiagnosticSettingsOperations", - "DiagnosticSettingsCategoryOperations", - "ManagementGroupDiagnosticSettingsOperations", - "SubscriptionDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py deleted file mode 100644 index 2a8bd6ff50930..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py +++ /dev/null @@ -1,658 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._autoscale_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoscaleSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.aio.MonitorManagementClient`'s - :attr:`autoscale_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: _models.AutoscaleSettingResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: Union[_models.AutoscaleSettingResource, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AutoscaleSettingResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> None: - """Deletes and autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Gets an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @overload - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a - AutoscaleSettingResourcePatch type or a IO type. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(autoscale_setting_resource, (IO, bytes)): - _content = autoscale_setting_resource - else: - _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py deleted file mode 100644 index 87ee26a26935b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ /dev/null @@ -1,198 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DiagnosticSettingsCategoryOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.aio.MonitorManagementClient`'s - :attr:`diagnostic_settings_category` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: - """Gets the diagnostic settings category for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.DiagnosticSettingsCategoryResource"]: - """Lists the diagnostic settings categories for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsCategoryResource or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py deleted file mode 100644 index 10924aeb47815..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ /dev/null @@ -1,388 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._diagnostic_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.aio.MonitorManagementClient`'s - :attr:`diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @overload - async def create_or_update( - self, - resource_uri: str, - name: str, - parameters: _models.DiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.DiagnosticSettingsResource"]: - """Gets the active diagnostic settings list for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py deleted file mode 100644 index 51c02a4408ca5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ /dev/null @@ -1,415 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._management_group_diagnostic_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ManagementGroupDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.aio.MonitorManagementClient`'s - :attr:`management_group_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, management_group_id: str, name: str, **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Gets the active management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @overload - async def create_or_update( - self, - management_group_id: str, - name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - management_group_id: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - management_group_id: str, - name: str, - parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - ManagementGroupDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") - - request = build_create_or_update_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @distributed_trace - def list( - self, management_group_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagementGroupDiagnosticSettingsResource"]: - """Gets the active management group diagnostic settings list for the specified management group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py deleted file mode 100644 index 7907cef27da3c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._predictive_metric_operations import build_get_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PredictiveMetricOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.aio.MonitorManagementClient`'s - :attr:`predictive_metric` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - timespan: str, - interval: datetime.timedelta, - metric_namespace: str, - metric_name: str, - aggregation: str, - **kwargs: Any - ) -> _models.PredictiveResponse: - """get predictive autoscale metric future data. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Required. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Required. - :type interval: ~datetime.timedelta - :param metric_namespace: Metric namespace to query metric definitions for. Required. - :type metric_namespace: str - :param metric_name: 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'**. Required. - :type metric_name: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. - :type aggregation: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PredictiveResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - timespan=timespan, - interval=interval, - metric_namespace=metric_namespace, - metric_name=metric_name, - aggregation=aggregation, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PredictiveResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py deleted file mode 100644 index f79a002ba422b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ /dev/null @@ -1,376 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._subscription_diagnostic_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SubscriptionDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.aio.MonitorManagementClient`'s - :attr:`subscription_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: - """Gets the active subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @overload - async def create_or_update( - self, - name: str, - parameters: _models.SubscriptionDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - SubscriptionDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") - - request = build_create_or_update_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @distributed_trace_async - async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Deletes existing subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.SubscriptionDiagnosticSettingsResource"]: - """Gets the active subscription diagnostic settings list for the specified subscriptionId. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionDiagnosticSettingsResource or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py deleted file mode 100644 index aaaecfe7ecb44..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AutoscaleErrorResponse -from ._models_py3 import AutoscaleErrorResponseError -from ._models_py3 import AutoscaleNotification -from ._models_py3 import AutoscaleProfile -from ._models_py3 import AutoscaleSettingResource -from ._models_py3 import AutoscaleSettingResourceCollection -from ._models_py3 import AutoscaleSettingResourcePatch -from ._models_py3 import DiagnosticSettingsCategoryResource -from ._models_py3 import DiagnosticSettingsCategoryResourceCollection -from ._models_py3 import DiagnosticSettingsResource -from ._models_py3 import DiagnosticSettingsResourceCollection -from ._models_py3 import EmailNotification -from ._models_py3 import ErrorResponse -from ._models_py3 import LogSettings -from ._models_py3 import ManagementGroupDiagnosticSettingsResource -from ._models_py3 import ManagementGroupDiagnosticSettingsResourceCollection -from ._models_py3 import ManagementGroupLogSettings -from ._models_py3 import MetricSettings -from ._models_py3 import MetricTrigger -from ._models_py3 import PredictiveAutoscalePolicy -from ._models_py3 import PredictiveResponse -from ._models_py3 import PredictiveValue -from ._models_py3 import Recurrence -from ._models_py3 import RecurrentSchedule -from ._models_py3 import Resource -from ._models_py3 import RetentionPolicy -from ._models_py3 import ScaleAction -from ._models_py3 import ScaleCapacity -from ._models_py3 import ScaleRule -from ._models_py3 import ScaleRuleMetricDimension -from ._models_py3 import SubscriptionDiagnosticSettingsResource -from ._models_py3 import SubscriptionDiagnosticSettingsResourceCollection -from ._models_py3 import SubscriptionLogSettings -from ._models_py3 import SystemData -from ._models_py3 import TimeWindow -from ._models_py3 import WebhookNotification - -from ._monitor_management_client_enums import CategoryType -from ._monitor_management_client_enums import ComparisonOperationType -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import MetricStatisticType -from ._monitor_management_client_enums import PredictiveAutoscalePolicyScaleMode -from ._monitor_management_client_enums import RecurrenceFrequency -from ._monitor_management_client_enums import ScaleDirection -from ._monitor_management_client_enums import ScaleRuleMetricDimensionOperationType -from ._monitor_management_client_enums import ScaleType -from ._monitor_management_client_enums import TimeAggregationType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoscaleErrorResponse", - "AutoscaleErrorResponseError", - "AutoscaleNotification", - "AutoscaleProfile", - "AutoscaleSettingResource", - "AutoscaleSettingResourceCollection", - "AutoscaleSettingResourcePatch", - "DiagnosticSettingsCategoryResource", - "DiagnosticSettingsCategoryResourceCollection", - "DiagnosticSettingsResource", - "DiagnosticSettingsResourceCollection", - "EmailNotification", - "ErrorResponse", - "LogSettings", - "ManagementGroupDiagnosticSettingsResource", - "ManagementGroupDiagnosticSettingsResourceCollection", - "ManagementGroupLogSettings", - "MetricSettings", - "MetricTrigger", - "PredictiveAutoscalePolicy", - "PredictiveResponse", - "PredictiveValue", - "Recurrence", - "RecurrentSchedule", - "Resource", - "RetentionPolicy", - "ScaleAction", - "ScaleCapacity", - "ScaleRule", - "ScaleRuleMetricDimension", - "SubscriptionDiagnosticSettingsResource", - "SubscriptionDiagnosticSettingsResourceCollection", - "SubscriptionLogSettings", - "SystemData", - "TimeWindow", - "WebhookNotification", - "CategoryType", - "ComparisonOperationType", - "CreatedByType", - "MetricStatisticType", - "PredictiveAutoscalePolicyScaleMode", - "RecurrenceFrequency", - "ScaleDirection", - "ScaleRuleMetricDimensionOperationType", - "ScaleType", - "TimeAggregationType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py deleted file mode 100644 index 3ab1eeb672992..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2116 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AutoscaleErrorResponse(_serialization.Model): - """Describes the format of Error response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleErrorResponseError - :ivar system_data: The system metadata related to the response. - :vartype system_data: ~azure.mgmt.monitor.v2021_05_01_preview.models.SystemData - """ - - _validation = { - "system_data": {"readonly": True}, - } - - _attribute_map = { - "error": {"key": "error", "type": "AutoscaleErrorResponseError"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleErrorResponseError - """ - super().__init__(**kwargs) - self.error = error - self.system_data = None - - -class AutoscaleErrorResponseError(_serialization.Model): - """The error object. - - :ivar code: One of a server-defined set of error codes. - :vartype code: str - :ivar message: A human-readable representation of the error. - :vartype message: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar details: A human-readable representation of the error's details. - :vartype details: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "str"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - target: Optional[str] = None, - details: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: One of a server-defined set of error codes. - :paramtype code: str - :keyword message: A human-readable representation of the error. - :paramtype message: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword details: A human-readable representation of the error's details. - :paramtype details: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - self.target = target - self.details = details - - -class AutoscaleNotification(_serialization.Model): - """Autoscale notification. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar operation: the operation associated with the notification and its value must be "scale". - Required. Default value is "Scale". - :vartype operation: str - :ivar email: the email notification. - :vartype email: ~azure.mgmt.monitor.v2021_05_01_preview.models.EmailNotification - :ivar webhooks: the collection of webhook notifications. - :vartype webhooks: list[~azure.mgmt.monitor.v2021_05_01_preview.models.WebhookNotification] - """ - - _validation = { - "operation": {"required": True, "constant": True}, - } - - _attribute_map = { - "operation": {"key": "operation", "type": "str"}, - "email": {"key": "email", "type": "EmailNotification"}, - "webhooks": {"key": "webhooks", "type": "[WebhookNotification]"}, - } - - operation = "Scale" - - def __init__( - self, - *, - email: Optional["_models.EmailNotification"] = None, - webhooks: Optional[List["_models.WebhookNotification"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword email: the email notification. - :paramtype email: ~azure.mgmt.monitor.v2021_05_01_preview.models.EmailNotification - :keyword webhooks: the collection of webhook notifications. - :paramtype webhooks: list[~azure.mgmt.monitor.v2021_05_01_preview.models.WebhookNotification] - """ - super().__init__(**kwargs) - self.email = email - self.webhooks = webhooks - - -class AutoscaleProfile(_serialization.Model): - """Autoscale profile. - - All required parameters must be populated in order to send to Azure. - - :ivar name: the name of the profile. Required. - :vartype name: str - :ivar capacity: the number of instances that can be used during this profile. Required. - :vartype capacity: ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleCapacity - :ivar rules: the collection of rules that provide the triggers and parameters for the scaling - action. A maximum of 10 rules can be specified. Required. - :vartype rules: list[~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleRule] - :ivar fixed_date: the specific date-time for the profile. This element is not used if the - Recurrence element is used. - :vartype fixed_date: ~azure.mgmt.monitor.v2021_05_01_preview.models.TimeWindow - :ivar recurrence: the repeating times at which this profile begins. This element is not used if - the FixedDate element is used. - :vartype recurrence: ~azure.mgmt.monitor.v2021_05_01_preview.models.Recurrence - """ - - _validation = { - "name": {"required": True}, - "capacity": {"required": True}, - "rules": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "capacity": {"key": "capacity", "type": "ScaleCapacity"}, - "rules": {"key": "rules", "type": "[ScaleRule]"}, - "fixed_date": {"key": "fixedDate", "type": "TimeWindow"}, - "recurrence": {"key": "recurrence", "type": "Recurrence"}, - } - - def __init__( - self, - *, - name: str, - capacity: "_models.ScaleCapacity", - rules: List["_models.ScaleRule"], - fixed_date: Optional["_models.TimeWindow"] = None, - recurrence: Optional["_models.Recurrence"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: the name of the profile. Required. - :paramtype name: str - :keyword capacity: the number of instances that can be used during this profile. Required. - :paramtype capacity: ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleCapacity - :keyword rules: the collection of rules that provide the triggers and parameters for the - scaling action. A maximum of 10 rules can be specified. Required. - :paramtype rules: list[~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleRule] - :keyword fixed_date: the specific date-time for the profile. This element is not used if the - Recurrence element is used. - :paramtype fixed_date: ~azure.mgmt.monitor.v2021_05_01_preview.models.TimeWindow - :keyword recurrence: the repeating times at which this profile begins. This element is not used - if the FixedDate element is used. - :paramtype recurrence: ~azure.mgmt.monitor.v2021_05_01_preview.models.Recurrence - """ - super().__init__(**kwargs) - self.name = name - self.capacity = capacity - self.rules = rules - self.fixed_date = fixed_date - self.recurrence = recurrence - - -class AutoscaleSettingResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The autoscale setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can - be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags - can be provided for a resource. Each tag must have a key no greater in length than 128 - characters and a value no greater in length than 256 characters. - :vartype tags: dict[str, str] - :ivar system_data: The system metadata related to the response. - :vartype system_data: ~azure.mgmt.monitor.v2021_05_01_preview.models.SystemData - :ivar profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. Required. - :vartype profiles: list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleProfile] - :ivar notifications: the collection of notifications. - :vartype notifications: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleNotification] - :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :vartype enabled: bool - :ivar predictive_autoscale_policy: the predictive autoscale policy mode. - :vartype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveAutoscalePolicy - :ivar name_properties_name: the name of the autoscale setting. - :vartype name_properties_name: str - :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting - should be added to. - :vartype target_resource_uri: str - :ivar target_resource_location: the location of the resource that the autoscale setting should - be added to. - :vartype target_resource_location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": True}, - "profiles": {"required": True, "max_items": 20, "min_items": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, - "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "predictive_autoscale_policy": { - "key": "properties.predictiveAutoscalePolicy", - "type": "PredictiveAutoscalePolicy", - }, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, - "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - profiles: List["_models.AutoscaleProfile"], - tags: Optional[Dict[str, str]] = None, - notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: bool = False, - predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, - name_properties_name: Optional[str] = None, - target_resource_uri: Optional[str] = None, - target_resource_location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags - can be used in viewing and grouping this resource (across resource groups). A maximum of 15 - tags can be provided for a resource. Each tag must have a key no greater in length than 128 - characters and a value no greater in length than 256 characters. - :paramtype tags: dict[str, str] - :keyword profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. Required. - :paramtype profiles: list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleProfile] - :keyword notifications: the collection of notifications. - :paramtype notifications: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleNotification] - :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :paramtype enabled: bool - :keyword predictive_autoscale_policy: the predictive autoscale policy mode. - :paramtype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveAutoscalePolicy - :keyword name_properties_name: the name of the autoscale setting. - :paramtype name_properties_name: str - :keyword target_resource_uri: the resource identifier of the resource that the autoscale - setting should be added to. - :paramtype target_resource_uri: str - :keyword target_resource_location: the location of the resource that the autoscale setting - should be added to. - :paramtype target_resource_location: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.system_data = None - self.profiles = profiles - self.notifications = notifications - self.enabled = enabled - self.predictive_autoscale_policy = predictive_autoscale_policy - self.name_properties_name = name_properties_name - self.target_resource_uri = target_resource_uri - self.target_resource_location = target_resource_location - - -class AutoscaleSettingResourceCollection(_serialization.Model): - """Represents a collection of autoscale setting resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values for the autoscale setting resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource] - :ivar next_link: URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AutoscaleSettingResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: the values for the autoscale setting resources. Required. - :paramtype value: list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource] - :keyword next_link: URL to get the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AutoscaleSettingResourcePatch(_serialization.Model): - """The autoscale setting object for patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. - :vartype profiles: list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleProfile] - :ivar notifications: the collection of notifications. - :vartype notifications: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleNotification] - :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :vartype enabled: bool - :ivar predictive_autoscale_policy: the predictive autoscale policy mode. - :vartype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveAutoscalePolicy - :ivar name: the name of the autoscale setting. - :vartype name: str - :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting - should be added to. - :vartype target_resource_uri: str - :ivar target_resource_location: the location of the resource that the autoscale setting should - be added to. - :vartype target_resource_location: str - """ - - _validation = { - "profiles": {"max_items": 20, "min_items": 0}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, - "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "predictive_autoscale_policy": { - "key": "properties.predictiveAutoscalePolicy", - "type": "PredictiveAutoscalePolicy", - }, - "name": {"key": "properties.name", "type": "str"}, - "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, - "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - profiles: Optional[List["_models.AutoscaleProfile"]] = None, - notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: bool = False, - predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, - name: Optional[str] = None, - target_resource_uri: Optional[str] = None, - target_resource_location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. - :paramtype profiles: list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleProfile] - :keyword notifications: the collection of notifications. - :paramtype notifications: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleNotification] - :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :paramtype enabled: bool - :keyword predictive_autoscale_policy: the predictive autoscale policy mode. - :paramtype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveAutoscalePolicy - :keyword name: the name of the autoscale setting. - :paramtype name: str - :keyword target_resource_uri: the resource identifier of the resource that the autoscale - setting should be added to. - :paramtype target_resource_uri: str - :keyword target_resource_location: the location of the resource that the autoscale setting - should be added to. - :paramtype target_resource_location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.profiles = profiles - self.notifications = notifications - self.enabled = enabled - self.predictive_autoscale_policy = predictive_autoscale_policy - self.name = name - self.target_resource_uri = target_resource_uri - self.target_resource_location = target_resource_location - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DiagnosticSettingsCategoryResource(Resource): - """The diagnostic settings category resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system metadata related to this resource. - :vartype system_data: ~azure.mgmt.monitor.v2021_05_01_preview.models.SystemData - :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics" - and "Logs". - :vartype category_type: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.CategoryType - :ivar category_groups: the collection of what category groups are supported. - :vartype category_groups: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "category_type": {"key": "properties.categoryType", "type": "str"}, - "category_groups": {"key": "properties.categoryGroups", "type": "[str]"}, - } - - def __init__( - self, - *, - category_type: Optional[Union[str, "_models.CategoryType"]] = None, - category_groups: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword category_type: The type of the diagnostic settings category. Known values are: - "Metrics" and "Logs". - :paramtype category_type: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.CategoryType - :keyword category_groups: the collection of what category groups are supported. - :paramtype category_groups: list[str] - """ - super().__init__(**kwargs) - self.system_data = None - self.category_type = category_type - self.category_groups = category_groups - - -class DiagnosticSettingsCategoryResourceCollection(_serialization.Model): - """Represents a collection of diagnostic setting category resources. - - :ivar value: The collection of diagnostic settings category resources. - :vartype value: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DiagnosticSettingsCategoryResource]"}, - } - - def __init__( - self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection of diagnostic settings category resources. - :paramtype value: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] - """ - super().__init__(**kwargs) - self.value = value - - -class DiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes - """The diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system metadata related to this resource. - :vartype system_data: ~azure.mgmt.monitor.v2021_05_01_preview.models.SystemData - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to - maintain backwards compatibility. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :vartype event_hub_name: str - :ivar metrics: The list of metric settings. - :vartype metrics: list[~azure.mgmt.monitor.v2021_05_01_preview.models.MetricSettings] - :ivar logs: The list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2021_05_01_preview.models.LogSettings] - :ivar workspace_id: 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. - :vartype workspace_id: str - :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you - would like to send Diagnostic Logs. - :vartype marketplace_partner_id: str - :ivar log_analytics_destination_type: 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: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :vartype log_analytics_destination_type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, - "metrics": {"key": "properties.metrics", "type": "[MetricSettings]"}, - "logs": {"key": "properties.logs", "type": "[LogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - "marketplace_partner_id": {"key": "properties.marketplacePartnerId", "type": "str"}, - "log_analytics_destination_type": {"key": "properties.logAnalyticsDestinationType", "type": "str"}, - } - - def __init__( - self, - *, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - event_hub_name: Optional[str] = None, - metrics: Optional[List["_models.MetricSettings"]] = None, - logs: Optional[List["_models.LogSettings"]] = None, - workspace_id: Optional[str] = None, - marketplace_partner_id: Optional[str] = None, - log_analytics_destination_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here - to maintain backwards compatibility. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :paramtype event_hub_name: str - :keyword metrics: The list of metric settings. - :paramtype metrics: list[~azure.mgmt.monitor.v2021_05_01_preview.models.MetricSettings] - :keyword logs: The list of logs settings. - :paramtype logs: list[~azure.mgmt.monitor.v2021_05_01_preview.models.LogSettings] - :keyword workspace_id: 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. - :paramtype workspace_id: str - :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :paramtype marketplace_partner_id: str - :keyword log_analytics_destination_type: 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: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :paramtype log_analytics_destination_type: str - """ - super().__init__(**kwargs) - self.system_data = None - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.event_hub_name = event_hub_name - self.metrics = metrics - self.logs = logs - self.workspace_id = workspace_id - self.marketplace_partner_id = marketplace_partner_id - self.log_analytics_destination_type = log_analytics_destination_type - - -class DiagnosticSettingsResourceCollection(_serialization.Model): - """Represents a collection of alert rule resources. - - :ivar value: The collection of diagnostic settings resources;. - :vartype value: list[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DiagnosticSettingsResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The collection of diagnostic settings resources;. - :paramtype value: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource] - """ - super().__init__(**kwargs) - self.value = value - - -class EmailNotification(_serialization.Model): - """Email notification of an autoscale event. - - :ivar send_to_subscription_administrator: a value indicating whether to send email to - subscription administrator. - :vartype send_to_subscription_administrator: bool - :ivar send_to_subscription_co_administrators: a value indicating whether to send email to - subscription co-administrators. - :vartype send_to_subscription_co_administrators: bool - :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case - this attribute will be ignored. - :vartype custom_emails: list[str] - """ - - _attribute_map = { - "send_to_subscription_administrator": {"key": "sendToSubscriptionAdministrator", "type": "bool"}, - "send_to_subscription_co_administrators": {"key": "sendToSubscriptionCoAdministrators", "type": "bool"}, - "custom_emails": {"key": "customEmails", "type": "[str]"}, - } - - def __init__( - self, - *, - send_to_subscription_administrator: bool = False, - send_to_subscription_co_administrators: bool = False, - custom_emails: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword send_to_subscription_administrator: a value indicating whether to send email to - subscription administrator. - :paramtype send_to_subscription_administrator: bool - :keyword send_to_subscription_co_administrators: a value indicating whether to send email to - subscription co-administrators. - :paramtype send_to_subscription_co_administrators: bool - :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case - this attribute will be ignored. - :paramtype custom_emails: list[str] - """ - super().__init__(**kwargs) - self.send_to_subscription_administrator = send_to_subscription_administrator - self.send_to_subscription_co_administrators = send_to_subscription_co_administrators - self.custom_emails = custom_emails - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class LogSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: 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. - :vartype category: str - :ivar category_group: Name of a Diagnostic Log category group 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. - :vartype category_group: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this log. - :vartype retention_policy: ~azure.mgmt.monitor.v2021_05_01_preview.models.RetentionPolicy - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "category_group": {"key": "categoryGroup", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - enabled: bool, - category: Optional[str] = None, - category_group: Optional[str] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword category: 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. - :paramtype category: str - :keyword category_group: Name of a Diagnostic Log category group 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. - :paramtype category_group: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this log. - :paramtype retention_policy: ~azure.mgmt.monitor.v2021_05_01_preview.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.category = category - self.category_group = category_group - self.enabled = enabled - self.retention_policy = retention_policy - - -class ManagementGroupDiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes - """The management group diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system metadata related to this resource. - :vartype system_data: ~azure.mgmt.monitor.v2021_05_01_preview.models.SystemData - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to - maintain backwards compatibility. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :vartype event_hub_name: str - :ivar logs: The list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupLogSettings] - :ivar workspace_id: 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. - :vartype workspace_id: str - :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you - would like to send Diagnostic Logs. - :vartype marketplace_partner_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, - "logs": {"key": "properties.logs", "type": "[ManagementGroupLogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - "marketplace_partner_id": {"key": "properties.marketplacePartnerId", "type": "str"}, - } - - def __init__( - self, - *, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - event_hub_name: Optional[str] = None, - logs: Optional[List["_models.ManagementGroupLogSettings"]] = None, - workspace_id: Optional[str] = None, - marketplace_partner_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here - to maintain backwards compatibility. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :paramtype event_hub_name: str - :keyword logs: The list of logs settings. - :paramtype logs: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupLogSettings] - :keyword workspace_id: 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. - :paramtype workspace_id: str - :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :paramtype marketplace_partner_id: str - """ - super().__init__(**kwargs) - self.system_data = None - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.event_hub_name = event_hub_name - self.logs = logs - self.workspace_id = workspace_id - self.marketplace_partner_id = marketplace_partner_id - - -class ManagementGroupDiagnosticSettingsResourceCollection(_serialization.Model): - """Represents a collection of management group diagnostic settings resources. - - :ivar value: The collection of management group diagnostic settings resources. - :vartype value: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ManagementGroupDiagnosticSettingsResource]"}, - } - - def __init__( - self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection of management group diagnostic settings resources. - :paramtype value: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] - """ - super().__init__(**kwargs) - self.value = value - - -class ManagementGroupLogSettings(_serialization.Model): - """Part of Management Group diagnostic setting. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: Name of a Management Group Diagnostic Log category for a resource type this - setting is applied to. - :vartype category: str - :ivar category_group: Name of a Management Group Diagnostic Log category group for a resource - type this setting is applied to. - :vartype category_group: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "category_group": {"key": "categoryGroup", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword category: Name of a Management Group Diagnostic Log category for a resource type this - setting is applied to. - :paramtype category: str - :keyword category_group: Name of a Management Group Diagnostic Log category group for a - resource type this setting is applied to. - :paramtype category_group: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.category = category - self.category_group = category_group - self.enabled = enabled - - -class MetricSettings(_serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - All required parameters must be populated in order to send to Azure. - - :ivar time_grain: the timegrain of the metric in ISO8601 format. - :vartype time_grain: ~datetime.timedelta - :ivar category: 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. - :vartype category: str - :ivar enabled: a value indicating whether this category is enabled. Required. - :vartype enabled: bool - :ivar retention_policy: the retention policy for this category. - :vartype retention_policy: ~azure.mgmt.monitor.v2021_05_01_preview.models.RetentionPolicy - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "duration"}, - "category": {"key": "category", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - enabled: bool, - time_grain: Optional[datetime.timedelta] = None, - category: Optional[str] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_grain: the timegrain of the metric in ISO8601 format. - :paramtype time_grain: ~datetime.timedelta - :keyword category: 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. - :paramtype category: str - :keyword enabled: a value indicating whether this category is enabled. Required. - :paramtype enabled: bool - :keyword retention_policy: the retention policy for this category. - :paramtype retention_policy: ~azure.mgmt.monitor.v2021_05_01_preview.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.category = category - self.enabled = enabled - self.retention_policy = retention_policy - - -class MetricTrigger(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The trigger that results in a scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar metric_name: the name of the metric that defines what the rule monitors. Required. - :vartype metric_name: str - :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. - :vartype metric_namespace: str - :ivar metric_resource_uri: the resource identifier of the resource the rule monitors. Required. - :vartype metric_resource_uri: str - :ivar metric_resource_location: the location of the resource the rule monitors. - :vartype metric_resource_location: str - :ivar time_grain: 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. - Required. - :vartype time_grain: ~datetime.timedelta - :ivar statistic: the metric statistic type. How the metrics from multiple instances are - combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". - :vartype statistic: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.MetricStatisticType - :ivar time_window: 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. Required. - :vartype time_window: ~datetime.timedelta - :ivar time_aggregation: time aggregation type. How the data that is collected should be - combined over time. The default value is Average. Required. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", and "Last". - :vartype time_aggregation: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.TimeAggregationType - :ivar operator: the operator that is used to compare the metric data and the threshold. - Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :vartype operator: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.ComparisonOperationType - :ivar threshold: the threshold of the metric that triggers the scale action. Required. - :vartype threshold: float - :ivar dimensions: List of dimension conditions. For example: - [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :vartype dimensions: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleRuleMetricDimension] - :ivar divide_per_instance: a value indicating whether metric should divide per instance. - :vartype divide_per_instance: bool - """ - - _validation = { - "metric_name": {"required": True}, - "metric_resource_uri": {"required": True}, - "time_grain": {"required": True}, - "statistic": {"required": True}, - "time_window": {"required": True}, - "time_aggregation": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "metric_name": {"key": "metricName", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "metric_resource_uri": {"key": "metricResourceUri", "type": "str"}, - "metric_resource_location": {"key": "metricResourceLocation", "type": "str"}, - "time_grain": {"key": "timeGrain", "type": "duration"}, - "statistic": {"key": "statistic", "type": "str"}, - "time_window": {"key": "timeWindow", "type": "duration"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "dimensions": {"key": "dimensions", "type": "[ScaleRuleMetricDimension]"}, - "divide_per_instance": {"key": "dividePerInstance", "type": "bool"}, - } - - def __init__( - self, - *, - metric_name: str, - metric_resource_uri: str, - time_grain: datetime.timedelta, - statistic: Union[str, "_models.MetricStatisticType"], - time_window: datetime.timedelta, - time_aggregation: Union[str, "_models.TimeAggregationType"], - operator: Union[str, "_models.ComparisonOperationType"], - threshold: float, - metric_namespace: Optional[str] = None, - metric_resource_location: Optional[str] = None, - dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, - divide_per_instance: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric_name: the name of the metric that defines what the rule monitors. Required. - :paramtype metric_name: str - :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. - :paramtype metric_namespace: str - :keyword metric_resource_uri: the resource identifier of the resource the rule monitors. - Required. - :paramtype metric_resource_uri: str - :keyword metric_resource_location: the location of the resource the rule monitors. - :paramtype metric_resource_location: str - :keyword time_grain: 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. Required. - :paramtype time_grain: ~datetime.timedelta - :keyword statistic: the metric statistic type. How the metrics from multiple instances are - combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". - :paramtype statistic: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.MetricStatisticType - :keyword time_window: 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. Required. - :paramtype time_window: ~datetime.timedelta - :keyword time_aggregation: time aggregation type. How the data that is collected should be - combined over time. The default value is Average. Required. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", and "Last". - :paramtype time_aggregation: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.TimeAggregationType - :keyword operator: the operator that is used to compare the metric data and the threshold. - Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :paramtype operator: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.ComparisonOperationType - :keyword threshold: the threshold of the metric that triggers the scale action. Required. - :paramtype threshold: float - :keyword dimensions: List of dimension conditions. For example: - [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :paramtype dimensions: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleRuleMetricDimension] - :keyword divide_per_instance: a value indicating whether metric should divide per instance. - :paramtype divide_per_instance: bool - """ - super().__init__(**kwargs) - self.metric_name = metric_name - self.metric_namespace = metric_namespace - self.metric_resource_uri = metric_resource_uri - self.metric_resource_location = metric_resource_location - self.time_grain = time_grain - self.statistic = statistic - self.time_window = time_window - self.time_aggregation = time_aggregation - self.operator = operator - self.threshold = threshold - self.dimensions = dimensions - self.divide_per_instance = divide_per_instance - - -class PredictiveAutoscalePolicy(_serialization.Model): - """The parameters for enabling predictive autoscale. - - All required parameters must be populated in order to send to Azure. - - :ivar scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", - "ForecastOnly", and "Enabled". - :vartype scale_mode: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode - :ivar scale_look_ahead_time: the amount of time to specify by which instances are launched in - advance. It must be between 1 minute and 60 minutes in ISO 8601 format. - :vartype scale_look_ahead_time: ~datetime.timedelta - """ - - _validation = { - "scale_mode": {"required": True}, - } - - _attribute_map = { - "scale_mode": {"key": "scaleMode", "type": "str"}, - "scale_look_ahead_time": {"key": "scaleLookAheadTime", "type": "duration"}, - } - - def __init__( - self, - *, - scale_mode: Union[str, "_models.PredictiveAutoscalePolicyScaleMode"], - scale_look_ahead_time: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", - "ForecastOnly", and "Enabled". - :paramtype scale_mode: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode - :keyword scale_look_ahead_time: the amount of time to specify by which instances are launched - in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. - :paramtype scale_look_ahead_time: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.scale_mode = scale_mode - self.scale_look_ahead_time = scale_look_ahead_time - - -class PredictiveResponse(_serialization.Model): - """The response to a metrics query. - - :ivar timespan: 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. - :vartype timespan: str - :ivar interval: 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. - :vartype interval: ~datetime.timedelta - :ivar metric_name: The metrics being queried. - :vartype metric_name: str - :ivar target_resource_id: resource of the predictive metric. - :vartype target_resource_id: str - :ivar data: the value of the collection. - :vartype data: list[~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveValue] - """ - - _attribute_map = { - "timespan": {"key": "timespan", "type": "str"}, - "interval": {"key": "interval", "type": "duration"}, - "metric_name": {"key": "metricName", "type": "str"}, - "target_resource_id": {"key": "targetResourceId", "type": "str"}, - "data": {"key": "data", "type": "[PredictiveValue]"}, - } - - def __init__( - self, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metric_name: Optional[str] = None, - target_resource_id: Optional[str] = None, - data: Optional[List["_models.PredictiveValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword timespan: 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. - :paramtype timespan: str - :keyword interval: 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. - :paramtype interval: ~datetime.timedelta - :keyword metric_name: The metrics being queried. - :paramtype metric_name: str - :keyword target_resource_id: resource of the predictive metric. - :paramtype target_resource_id: str - :keyword data: the value of the collection. - :paramtype data: list[~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveValue] - """ - super().__init__(**kwargs) - self.timespan = timespan - self.interval = interval - self.metric_name = metric_name - self.target_resource_id = target_resource_id - self.data = data - - -class PredictiveValue(_serialization.Model): - """Represents a predictive metric value in the given bucket. - - All required parameters must be populated in order to send to Azure. - - :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :vartype time_stamp: ~datetime.datetime - :ivar value: Predictive value in this time bucket. Required. - :vartype value: float - """ - - _validation = { - "time_stamp": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, - "value": {"key": "value", "type": "float"}, - } - - def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs: Any) -> None: - """ - :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :paramtype time_stamp: ~datetime.datetime - :keyword value: Predictive value in this time bucket. Required. - :paramtype value: float - """ - super().__init__(**kwargs) - self.time_stamp = time_stamp - self.value = value - - -class Recurrence(_serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate - element is used. - - All required parameters must be populated in order to send to Azure. - - :ivar frequency: 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. Required. Known values are: "None", "Second", - "Minute", "Hour", "Day", "Week", "Month", and "Year". - :vartype frequency: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.RecurrenceFrequency - :ivar schedule: the scheduling constraints for when the profile begins. Required. - :vartype schedule: ~azure.mgmt.monitor.v2021_05_01_preview.models.RecurrentSchedule - """ - - _validation = { - "frequency": {"required": True}, - "schedule": {"required": True}, - } - - _attribute_map = { - "frequency": {"key": "frequency", "type": "str"}, - "schedule": {"key": "schedule", "type": "RecurrentSchedule"}, - } - - def __init__( - self, - *, - frequency: Union[str, "_models.RecurrenceFrequency"], - schedule: "_models.RecurrentSchedule", - **kwargs: Any - ) -> None: - """ - :keyword frequency: 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. Required. Known values are: "None", - "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year". - :paramtype frequency: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.RecurrenceFrequency - :keyword schedule: the scheduling constraints for when the profile begins. Required. - :paramtype schedule: ~azure.mgmt.monitor.v2021_05_01_preview.models.RecurrentSchedule - """ - super().__init__(**kwargs) - self.frequency = frequency - self.schedule = schedule - - -class RecurrentSchedule(_serialization.Model): - """The scheduling constraints for when the profile begins. - - All required parameters must be populated in order to send to Azure. - - :ivar time_zone: 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. Required. - :vartype time_zone: str - :ivar days: the collection of days that the profile takes effect on. Possible values are Sunday - through Saturday. Required. - :vartype days: list[str] - :ivar hours: 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). Required. - :vartype hours: list[int] - :ivar minutes: A collection of minutes at which the profile takes effect at. Required. - :vartype minutes: list[int] - """ - - _validation = { - "time_zone": {"required": True}, - "days": {"required": True}, - "hours": {"required": True}, - "minutes": {"required": True}, - } - - _attribute_map = { - "time_zone": {"key": "timeZone", "type": "str"}, - "days": {"key": "days", "type": "[str]"}, - "hours": {"key": "hours", "type": "[int]"}, - "minutes": {"key": "minutes", "type": "[int]"}, - } - - def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any) -> None: - """ - :keyword time_zone: 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. Required. - :paramtype time_zone: str - :keyword days: the collection of days that the profile takes effect on. Possible values are - Sunday through Saturday. Required. - :paramtype days: list[str] - :keyword hours: 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). Required. - :paramtype hours: list[int] - :keyword minutes: A collection of minutes at which the profile takes effect at. Required. - :paramtype minutes: list[int] - """ - super().__init__(**kwargs) - self.time_zone = time_zone - self.days = days - self.hours = hours - self.minutes = minutes - - -class RetentionPolicy(_serialization.Model): - """Specifies the retention policy for the log. - - All required parameters must be populated in order to send to Azure. - - :ivar enabled: a value indicating whether the retention policy is enabled. Required. - :vartype enabled: bool - :ivar days: the number of days for the retention in days. A value of 0 will retain the events - indefinitely. Required. - :vartype days: int - """ - - _validation = { - "enabled": {"required": True}, - "days": {"required": True, "minimum": 0}, - } - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - "days": {"key": "days", "type": "int"}, - } - - def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: - """ - :keyword enabled: a value indicating whether the retention policy is enabled. Required. - :paramtype enabled: bool - :keyword days: the number of days for the retention in days. A value of 0 will retain the - events indefinitely. Required. - :paramtype days: int - """ - super().__init__(**kwargs) - self.enabled = enabled - self.days = days - - -class ScaleAction(_serialization.Model): - """The parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar direction: the scale direction. Whether the scaling action increases or decreases the - number of instances. Required. Known values are: "None", "Increase", and "Decrease". - :vartype direction: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleDirection - :ivar type: the type of action that should occur when the scale rule fires. Required. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". - :vartype type: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleType - :ivar value: the number of instances that are involved in the scaling action. This value must - be 1 or greater. The default value is 1. - :vartype value: str - :ivar cooldown: 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. Required. - :vartype cooldown: ~datetime.timedelta - """ - - _validation = { - "direction": {"required": True}, - "type": {"required": True}, - "cooldown": {"required": True}, - } - - _attribute_map = { - "direction": {"key": "direction", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "cooldown": {"key": "cooldown", "type": "duration"}, - } - - def __init__( - self, - *, - direction: Union[str, "_models.ScaleDirection"], - type: Union[str, "_models.ScaleType"], - cooldown: datetime.timedelta, - value: str = "1", - **kwargs: Any - ) -> None: - """ - :keyword direction: the scale direction. Whether the scaling action increases or decreases the - number of instances. Required. Known values are: "None", "Increase", and "Decrease". - :paramtype direction: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleDirection - :keyword type: the type of action that should occur when the scale rule fires. Required. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". - :paramtype type: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleType - :keyword value: the number of instances that are involved in the scaling action. This value - must be 1 or greater. The default value is 1. - :paramtype value: str - :keyword cooldown: 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. Required. - :paramtype cooldown: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.direction = direction - self.type = type - self.value = value - self.cooldown = cooldown - - -class ScaleCapacity(_serialization.Model): - """The number of instances that can be used during this profile. - - All required parameters must be populated in order to send to Azure. - - :ivar minimum: the minimum number of instances for the resource. Required. - :vartype minimum: str - :ivar maximum: 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. Required. - :vartype maximum: str - :ivar default: 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. - Required. - :vartype default: str - """ - - _validation = { - "minimum": {"required": True}, - "maximum": {"required": True}, - "default": {"required": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "str"}, - "maximum": {"key": "maximum", "type": "str"}, - "default": {"key": "default", "type": "str"}, - } - - def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs: Any) -> None: - """ - :keyword minimum: the minimum number of instances for the resource. Required. - :paramtype minimum: str - :keyword maximum: 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. Required. - :paramtype maximum: str - :keyword default: 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. - Required. - :paramtype default: str - """ - super().__init__(**kwargs) - self.minimum = minimum - self.maximum = maximum - self.default = default - - -class ScaleRule(_serialization.Model): - """A rule that provide the triggers and parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar metric_trigger: the trigger that results in a scaling action. Required. - :vartype metric_trigger: ~azure.mgmt.monitor.v2021_05_01_preview.models.MetricTrigger - :ivar scale_action: the parameters for the scaling action. Required. - :vartype scale_action: ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleAction - """ - - _validation = { - "metric_trigger": {"required": True}, - "scale_action": {"required": True}, - } - - _attribute_map = { - "metric_trigger": {"key": "metricTrigger", "type": "MetricTrigger"}, - "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, - } - - def __init__( - self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs: Any - ) -> None: - """ - :keyword metric_trigger: the trigger that results in a scaling action. Required. - :paramtype metric_trigger: ~azure.mgmt.monitor.v2021_05_01_preview.models.MetricTrigger - :keyword scale_action: the parameters for the scaling action. Required. - :paramtype scale_action: ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleAction - """ - super().__init__(**kwargs) - self.metric_trigger = metric_trigger - self.scale_action = scale_action - - -class ScaleRuleMetricDimension(_serialization.Model): - """Specifies an auto scale rule metric dimension. - - All required parameters must be populated in order to send to Azure. - - :ivar dimension_name: Name of the dimension. Required. - :vartype dimension_name: str - :ivar operator: 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. Required. - Known values are: "Equals" and "NotEquals". - :vartype operator: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType - :ivar values: list of dimension values. For example: ["App1","App2"]. Required. - :vartype values: list[str] - """ - - _validation = { - "dimension_name": {"required": True}, - "operator": {"required": True}, - "values": {"required": True}, - } - - _attribute_map = { - "dimension_name": {"key": "DimensionName", "type": "str"}, - "operator": {"key": "Operator", "type": "str"}, - "values": {"key": "Values", "type": "[str]"}, - } - - def __init__( - self, - *, - dimension_name: str, - operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], - values: List[str], - **kwargs: Any - ) -> None: - """ - :keyword dimension_name: Name of the dimension. Required. - :paramtype dimension_name: str - :keyword operator: 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. - Required. Known values are: "Equals" and "NotEquals". - :paramtype operator: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType - :keyword values: list of dimension values. For example: ["App1","App2"]. Required. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.dimension_name = dimension_name - self.operator = operator - self.values = values - - -class SubscriptionDiagnosticSettingsResource(Resource): # pylint: disable=too-many-instance-attributes - """The subscription diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system metadata related to this resource. - :vartype system_data: ~azure.mgmt.monitor.v2021_05_01_preview.models.SystemData - :ivar storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :vartype storage_account_id: str - :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to - maintain backwards compatibility. - :vartype service_bus_rule_id: str - :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :vartype event_hub_authorization_rule_id: str - :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :vartype event_hub_name: str - :ivar logs: The list of logs settings. - :vartype logs: list[~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionLogSettings] - :ivar workspace_id: 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. - :vartype workspace_id: str - :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you - would like to send Diagnostic Logs. - :vartype marketplace_partner_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, - "service_bus_rule_id": {"key": "properties.serviceBusRuleId", "type": "str"}, - "event_hub_authorization_rule_id": {"key": "properties.eventHubAuthorizationRuleId", "type": "str"}, - "event_hub_name": {"key": "properties.eventHubName", "type": "str"}, - "logs": {"key": "properties.logs", "type": "[SubscriptionLogSettings]"}, - "workspace_id": {"key": "properties.workspaceId", "type": "str"}, - "marketplace_partner_id": {"key": "properties.marketplacePartnerId", "type": "str"}, - } - - def __init__( - self, - *, - storage_account_id: Optional[str] = None, - service_bus_rule_id: Optional[str] = None, - event_hub_authorization_rule_id: Optional[str] = None, - event_hub_name: Optional[str] = None, - logs: Optional[List["_models.SubscriptionLogSettings"]] = None, - workspace_id: Optional[str] = None, - marketplace_partner_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_account_id: The resource ID of the storage account to which you would like to - send Diagnostic Logs. - :paramtype storage_account_id: str - :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here - to maintain backwards compatibility. - :paramtype service_bus_rule_id: str - :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :paramtype event_hub_authorization_rule_id: str - :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub - will be selected. - :paramtype event_hub_name: str - :keyword logs: The list of logs settings. - :paramtype logs: list[~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionLogSettings] - :keyword workspace_id: 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. - :paramtype workspace_id: str - :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :paramtype marketplace_partner_id: str - """ - super().__init__(**kwargs) - self.system_data = None - self.storage_account_id = storage_account_id - self.service_bus_rule_id = service_bus_rule_id - self.event_hub_authorization_rule_id = event_hub_authorization_rule_id - self.event_hub_name = event_hub_name - self.logs = logs - self.workspace_id = workspace_id - self.marketplace_partner_id = marketplace_partner_id - - -class SubscriptionDiagnosticSettingsResourceCollection(_serialization.Model): - """Represents a collection of subscription diagnostic settings resources. - - :ivar value: The collection of subscription diagnostic settings resources. - :vartype value: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[SubscriptionDiagnosticSettingsResource]"}, - } - - def __init__( - self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection of subscription diagnostic settings resources. - :paramtype value: - list[~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - """ - super().__init__(**kwargs) - self.value = value - - -class SubscriptionLogSettings(_serialization.Model): - """Part of Subscription diagnostic setting. Specifies the settings for a particular log. - - All required parameters must be populated in order to send to Azure. - - :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting - is applied to. - :vartype category: str - :ivar category_group: Name of a Subscription Diagnostic Log category group for a resource type - this setting is applied to. - :vartype category_group: str - :ivar enabled: a value indicating whether this log is enabled. Required. - :vartype enabled: bool - """ - - _validation = { - "enabled": {"required": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "category_group": {"key": "categoryGroup", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword category: Name of a Subscription Diagnostic Log category for a resource type this - setting is applied to. - :paramtype category: str - :keyword category_group: Name of a Subscription Diagnostic Log category group for a resource - type this setting is applied to. - :paramtype category_group: str - :keyword enabled: a value indicating whether this log is enabled. Required. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.category = category - self.category_group = category_group - self.enabled = enabled - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2021_05_01_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2021_05_01_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TimeWindow(_serialization.Model): - """A specific date-time for the profile. - - All required parameters must be populated in order to send to Azure. - - :ivar time_zone: 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. - :vartype time_zone: str - :ivar start: the start time for the profile in ISO 8601 format. Required. - :vartype start: ~datetime.datetime - :ivar end: the end time for the profile in ISO 8601 format. Required. - :vartype end: ~datetime.datetime - """ - - _validation = { - "start": {"required": True}, - "end": {"required": True}, - } - - _attribute_map = { - "time_zone": {"key": "timeZone", "type": "str"}, - "start": {"key": "start", "type": "iso-8601"}, - "end": {"key": "end", "type": "iso-8601"}, - } - - def __init__( - self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword time_zone: 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. - :paramtype time_zone: str - :keyword start: the start time for the profile in ISO 8601 format. Required. - :paramtype start: ~datetime.datetime - :keyword end: the end time for the profile in ISO 8601 format. Required. - :paramtype end: ~datetime.datetime - """ - super().__init__(**kwargs) - self.time_zone = time_zone - self.start = start - self.end = end - - -class WebhookNotification(_serialization.Model): - """Webhook notification of an autoscale event. - - :ivar service_uri: the service address to receive the notification. - :vartype service_uri: str - :ivar properties: a property bag of settings. This value can be empty. - :vartype properties: dict[str, str] - """ - - _attribute_map = { - "service_uri": {"key": "serviceUri", "type": "str"}, - "properties": {"key": "properties", "type": "{str}"}, - } - - def __init__( - self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword service_uri: the service address to receive the notification. - :paramtype service_uri: str - :keyword properties: a property bag of settings. This value can be empty. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.service_uri = service_uri - self.properties = properties diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 9423c612ef556..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the diagnostic settings category.""" - - METRICS = "Metrics" - LOGS = "Logs" - - -class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the operator that is used to compare the metric data and the threshold.""" - - EQUALS = "Equals" - NOT_EQUALS = "NotEquals" - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the metric statistic type. How the metrics from multiple instances are combined.""" - - AVERAGE = "Average" - MIN = "Min" - MAX = "Max" - SUM = "Sum" - COUNT = "Count" - - -class PredictiveAutoscalePolicyScaleMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the predictive autoscale mode.""" - - DISABLED = "Disabled" - FORECAST_ONLY = "ForecastOnly" - ENABLED = "Enabled" - - -class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - NONE = "None" - SECOND = "Second" - MINUTE = "Minute" - HOUR = "Hour" - DAY = "Day" - WEEK = "Week" - MONTH = "Month" - YEAR = "Year" - - -class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the scale direction. Whether the scaling action increases or decreases the number of instances.""" - - NONE = "None" - INCREASE = "Increase" - DECREASE = "Decrease" - - -class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - EQUALS = "Equals" - NOT_EQUALS = "NotEquals" - - -class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the type of action that should occur when the scale rule fires.""" - - CHANGE_COUNT = "ChangeCount" - PERCENT_CHANGE_COUNT = "PercentChangeCount" - EXACT_COUNT = "ExactCount" - SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" - - -class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """time aggregation type. How the data that is collected should be combined over time. The default - value is Average. - """ - - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - COUNT = "Count" - LAST = "Last" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py deleted file mode 100644 index 526d8450f6ce4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._autoscale_settings_operations import AutoscaleSettingsOperations -from ._predictive_metric_operations import PredictiveMetricOperations -from ._diagnostic_settings_operations import DiagnosticSettingsOperations -from ._diagnostic_settings_category_operations import DiagnosticSettingsCategoryOperations -from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations -from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoscaleSettingsOperations", - "PredictiveMetricOperations", - "DiagnosticSettingsOperations", - "DiagnosticSettingsCategoryOperations", - "ManagementGroupDiagnosticSettingsOperations", - "SubscriptionDiagnosticSettingsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py deleted file mode 100644 index 58b7c033d782a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py +++ /dev/null @@ -1,845 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AutoscaleSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.MonitorManagementClient`'s - :attr:`autoscale_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: _models.AutoscaleSettingResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: Union[_models.AutoscaleSettingResource, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AutoscaleSettingResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> None: - """Deletes and autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def get( - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Gets an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @overload - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a - AutoscaleSettingResourcePatch type or a IO type. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(autoscale_setting_resource, (IO, bytes)): - _content = autoscale_setting_resource - else: - _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py deleted file mode 100644 index f2b7d01475228..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ /dev/null @@ -1,249 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DiagnosticSettingsCategoryOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.MonitorManagementClient`'s - :attr:`diagnostic_settings_category` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResource: - """Gets the diagnostic settings category for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsCategoryResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsCategoryResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsCategoryResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.DiagnosticSettingsCategoryResource"]: - """Lists the diagnostic settings categories for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsCategoryResource or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py deleted file mode 100644 index c7e8b738b8fdc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py +++ /dev/null @@ -1,487 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_uri: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.MonitorManagementClient`'s - :attr:`diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.DiagnosticSettingsResource: - """Gets the active diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @overload - def create_or_update( - self, - resource_uri: str, - name: str, - parameters: _models.DiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, resource_uri: str, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, resource_uri: str, name: str, parameters: Union[_models.DiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.DiagnosticSettingsResource: - """Creates or updates diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DiagnosticSettingsResource") - - request = build_create_or_update_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing diagnostic settings for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace - def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.DiagnosticSettingsResource"]: - """Gets the active diagnostic settings list for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.DiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py deleted file mode 100644 index 339da67553477..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ /dev/null @@ -1,526 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(management_group_id: str, name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagementGroupDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.MonitorManagementClient`'s - :attr:`management_group_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, management_group_id: str, name: str, **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Gets the active management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @overload - def create_or_update( - self, - management_group_id: str, - name: str, - parameters: _models.ManagementGroupDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - management_group_id: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - management_group_id: str, - name: str, - parameters: Union[_models.ManagementGroupDiagnosticSettingsResource, IO], - **kwargs: Any - ) -> _models.ManagementGroupDiagnosticSettingsResource: - """Creates or updates management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - ManagementGroupDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementGroupDiagnosticSettingsResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagementGroupDiagnosticSettingsResource") - - request = build_create_or_update_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, name: str, **kwargs: Any - ) -> None: - """Deletes existing management group diagnostic settings for the specified resource. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - management_group_id=management_group_id, - name=name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @distributed_trace - def list( - self, management_group_id: str, **kwargs: Any - ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResource"]: - """Gets the active management group diagnostic settings list for the specified management group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResource or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - management_group_id=management_group_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py deleted file mode 100644 index a3f0a967046db..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py +++ /dev/null @@ -1,193 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - *, - timespan: str, - interval: datetime.timedelta, - metric_namespace: str, - metric_name: str, - aggregation: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - _params["metricNamespace"] = _SERIALIZER.query("metric_namespace", metric_namespace, "str") - _params["metricName"] = _SERIALIZER.query("metric_name", metric_name, "str") - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PredictiveMetricOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.MonitorManagementClient`'s - :attr:`predictive_metric` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - timespan: str, - interval: datetime.timedelta, - metric_namespace: str, - metric_name: str, - aggregation: str, - **kwargs: Any - ) -> _models.PredictiveResponse: - """get predictive autoscale metric future data. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Required. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Required. - :type interval: ~datetime.timedelta - :param metric_namespace: Metric namespace to query metric definitions for. Required. - :type metric_namespace: str - :param metric_name: 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'**. Required. - :type metric_name: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. - :type aggregation: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PredictiveResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.PredictiveResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - timespan=timespan, - interval=interval, - metric_namespace=metric_namespace, - metric_name=metric_name, - aggregation=aggregation, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PredictiveResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py deleted file mode 100644 index 64d625a3b2f1b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ /dev/null @@ -1,481 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class SubscriptionDiagnosticSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_05_01_preview.MonitorManagementClient`'s - :attr:`subscription_diagnostic_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResource: - """Gets the active subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - request = build_get_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @overload - def create_or_update( - self, - name: str, - parameters: _models.SubscriptionDiagnosticSettingsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, name: str, parameters: Union[_models.SubscriptionDiagnosticSettingsResource, IO], **kwargs: Any - ) -> _models.SubscriptionDiagnosticSettingsResource: - """Creates or updates subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :param parameters: Parameters supplied to the operation. Is either a - SubscriptionDiagnosticSettingsResource type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionDiagnosticSettingsResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SubscriptionDiagnosticSettingsResource") - - request = build_create_or_update_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" - } - - @distributed_trace - def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Deletes existing subscription diagnostic settings for the specified resource. - - :param name: The name of the diagnostic setting. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.SubscriptionDiagnosticSettingsResource"]: - """Gets the active subscription diagnostic settings list for the specified subscriptionId. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionDiagnosticSettingsResource or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_configuration.py deleted file mode 100644 index 31e53c1331455..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-06-03-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-06-03-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_metadata.json deleted file mode 100644 index eb89105a0203d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2021-06-03-preview", - "total_api_version_list": ["2021-06-03-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "azure_monitor_workspaces": "AzureMonitorWorkspacesOperations", - "monitor_operations": "MonitorOperationsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_monitor_management_client.py deleted file mode 100644 index 609fd0d55392e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import AzureMonitorWorkspacesOperations, MonitorOperationsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar azure_monitor_workspaces: AzureMonitorWorkspacesOperations operations - :vartype azure_monitor_workspaces: - azure.mgmt.monitor.v2021_06_03_preview.operations.AzureMonitorWorkspacesOperations - :ivar monitor_operations: MonitorOperationsOperations operations - :vartype monitor_operations: - azure.mgmt.monitor.v2021_06_03_preview.operations.MonitorOperationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-06-03-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.azure_monitor_workspaces = AzureMonitorWorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.monitor_operations = MonitorOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_configuration.py deleted file mode 100644 index 798865c55f154..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-06-03-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-06-03-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_monitor_management_client.py deleted file mode 100644 index d510d97f581bf..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import AzureMonitorWorkspacesOperations, MonitorOperationsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar azure_monitor_workspaces: AzureMonitorWorkspacesOperations operations - :vartype azure_monitor_workspaces: - azure.mgmt.monitor.v2021_06_03_preview.aio.operations.AzureMonitorWorkspacesOperations - :ivar monitor_operations: MonitorOperationsOperations operations - :vartype monitor_operations: - azure.mgmt.monitor.v2021_06_03_preview.aio.operations.MonitorOperationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-06-03-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.azure_monitor_workspaces = AzureMonitorWorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.monitor_operations = MonitorOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/__init__.py deleted file mode 100644 index cc4f2ca90de6c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._azure_monitor_workspaces_operations import AzureMonitorWorkspacesOperations -from ._monitor_operations_operations import MonitorOperationsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureMonitorWorkspacesOperations", - "MonitorOperationsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_azure_monitor_workspaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_azure_monitor_workspaces_operations.py deleted file mode 100644 index 5fe2ed9588a8f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_azure_monitor_workspaces_operations.py +++ /dev/null @@ -1,670 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._azure_monitor_workspaces_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AzureMonitorWorkspacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_06_03_preview.aio.MonitorManagementClient`'s - :attr:`azure_monitor_workspaces` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureMonitorWorkspaceResource"]: - """Lists all workspaces in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorWorkspaceResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.AzureMonitorWorkspaceResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorWorkspaceResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AzureMonitorWorkspaceResource"]: - """Lists all workspaces in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorWorkspaceResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.AzureMonitorWorkspaceResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorWorkspaceResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/accounts"} - - @distributed_trace_async - async def get( - self, resource_group_name: str, azure_monitor_workspace_name: str, **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Returns the specific Azure Monitor workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.AzureMonitorWorkspaceResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } - - @overload - async def create( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: _models.AzureMonitorWorkspaceResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Create or update a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: Properties that need to be specified to create a new - workspace. Required. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Create or update a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: Properties that need to be specified to create a new - workspace. Required. - :type azure_monitor_workspace_properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Union[_models.AzureMonitorWorkspaceResource, IO], - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Create or update a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: Properties that need to be specified to create a new - workspace. Is either a AzureMonitorWorkspaceResource type or a IO type. Required. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorWorkspaceResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_workspace_properties, (IO, bytes)): - _content = azure_monitor_workspace_properties - else: - _json = self._serialize.body(azure_monitor_workspace_properties, "AzureMonitorWorkspaceResource") - - request = build_create_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } - - @overload - async def update( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Optional[_models.AzureMonitorWorkspaceResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Updates part of a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: The payload. Default value is None. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Updates part of a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: The payload. Default value is None. - :type azure_monitor_workspace_properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Optional[Union[_models.AzureMonitorWorkspaceResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Updates part of a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: The payload. Is either a - AzureMonitorWorkspaceResourceForUpdate type or a IO type. Default value is None. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorWorkspaceResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_workspace_properties, (IO, bytes)): - _content = azure_monitor_workspace_properties - else: - if azure_monitor_workspace_properties is not None: - _json = self._serialize.body( - azure_monitor_workspace_properties, "AzureMonitorWorkspaceResourceForUpdate" - ) - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, azure_monitor_workspace_name: str, **kwargs: Any - ) -> None: - """Delete a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_monitor_operations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_monitor_operations_operations.py deleted file mode 100644 index 03014bb531be7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_monitor_operations_operations.py +++ /dev/null @@ -1,134 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._monitor_operations_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class MonitorOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_06_03_preview.aio.MonitorManagementClient`'s - :attr:`monitor_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists available Operations for this Resource Provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_06_03_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Monitor/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/__init__.py deleted file mode 100644 index ed34ac23b1f54..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AzureMonitorWorkspace -from ._models_py3 import AzureMonitorWorkspaceDefaultIngestionSettings -from ._models_py3 import AzureMonitorWorkspaceMetrics -from ._models_py3 import AzureMonitorWorkspaceResource -from ._models_py3 import AzureMonitorWorkspaceResourceForUpdate -from ._models_py3 import AzureMonitorWorkspaceResourceListResult -from ._models_py3 import AzureMonitorWorkspaceResourceProperties -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import IngestionSettings -from ._models_py3 import Metrics -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import Resource -from ._models_py3 import SystemData -from ._models_py3 import TrackedResource - -from ._monitor_management_client_enums import ActionType -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import Origin -from ._monitor_management_client_enums import ProvisioningState -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureMonitorWorkspace", - "AzureMonitorWorkspaceDefaultIngestionSettings", - "AzureMonitorWorkspaceMetrics", - "AzureMonitorWorkspaceResource", - "AzureMonitorWorkspaceResourceForUpdate", - "AzureMonitorWorkspaceResourceListResult", - "AzureMonitorWorkspaceResourceProperties", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "IngestionSettings", - "Metrics", - "Operation", - "OperationDisplay", - "OperationListResult", - "Resource", - "SystemData", - "TrackedResource", - "ActionType", - "CreatedByType", - "Origin", - "ProvisioningState", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_models_py3.py deleted file mode 100644 index 8edc0aec3f9e5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_models_py3.py +++ /dev/null @@ -1,734 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AzureMonitorWorkspace(_serialization.Model): - """Properties of an Azure Monitor workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar account_id: The immutable ID of the Azure Monitor workspace. This property is read-only. - :vartype account_id: str - :ivar metrics: Information about metrics for the Azure Monitor workspace. - :vartype metrics: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceMetrics - :ivar provisioning_state: The provisioning state of the Azure Monitor workspace. Set to - Succeeded if everything is healthy. Known values are: "Creating", "Succeeded", "Deleting", - "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_06_03_preview.models.ProvisioningState - :ivar default_ingestion_settings: The Data Collection Rule and Endpoint used for ingestion by - default. - :vartype default_ingestion_settings: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceDefaultIngestionSettings - """ - - _validation = { - "account_id": {"readonly": True}, - "metrics": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "default_ingestion_settings": {"readonly": True}, - } - - _attribute_map = { - "account_id": {"key": "accountId", "type": "str"}, - "metrics": {"key": "metrics", "type": "AzureMonitorWorkspaceMetrics"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "default_ingestion_settings": { - "key": "defaultIngestionSettings", - "type": "AzureMonitorWorkspaceDefaultIngestionSettings", - }, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.account_id = None - self.metrics = None - self.provisioning_state = None - self.default_ingestion_settings = None - - -class IngestionSettings(_serialization.Model): - """Settings for data ingestion. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar data_collection_rule_resource_id: The Azure resource Id of the default data collection - rule for this workspace. - :vartype data_collection_rule_resource_id: str - :ivar data_collection_endpoint_resource_id: The Azure resource Id of the default data - collection endpoint for this workspace. - :vartype data_collection_endpoint_resource_id: str - """ - - _validation = { - "data_collection_rule_resource_id": {"readonly": True}, - "data_collection_endpoint_resource_id": {"readonly": True}, - } - - _attribute_map = { - "data_collection_rule_resource_id": {"key": "dataCollectionRuleResourceId", "type": "str"}, - "data_collection_endpoint_resource_id": {"key": "dataCollectionEndpointResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.data_collection_rule_resource_id = None - self.data_collection_endpoint_resource_id = None - - -class AzureMonitorWorkspaceDefaultIngestionSettings(IngestionSettings): - """The Data Collection Rule and Endpoint used for ingestion by default. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar data_collection_rule_resource_id: The Azure resource Id of the default data collection - rule for this workspace. - :vartype data_collection_rule_resource_id: str - :ivar data_collection_endpoint_resource_id: The Azure resource Id of the default data - collection endpoint for this workspace. - :vartype data_collection_endpoint_resource_id: str - """ - - _validation = { - "data_collection_rule_resource_id": {"readonly": True}, - "data_collection_endpoint_resource_id": {"readonly": True}, - } - - _attribute_map = { - "data_collection_rule_resource_id": {"key": "dataCollectionRuleResourceId", "type": "str"}, - "data_collection_endpoint_resource_id": {"key": "dataCollectionEndpointResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class Metrics(_serialization.Model): - """Information about metrics for the workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar prometheus_query_endpoint: The Prometheus query endpoint for the workspace. - :vartype prometheus_query_endpoint: str - :ivar internal_id: An internal identifier for the metrics container. Only to be used by the - system. - :vartype internal_id: str - """ - - _validation = { - "prometheus_query_endpoint": {"readonly": True}, - "internal_id": {"readonly": True}, - } - - _attribute_map = { - "prometheus_query_endpoint": {"key": "prometheusQueryEndpoint", "type": "str"}, - "internal_id": {"key": "internalId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.prometheus_query_endpoint = None - self.internal_id = None - - -class AzureMonitorWorkspaceMetrics(Metrics): - """Information about metrics for the Azure Monitor workspace. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar prometheus_query_endpoint: The Prometheus query endpoint for the workspace. - :vartype prometheus_query_endpoint: str - :ivar internal_id: An internal identifier for the metrics container. Only to be used by the - system. - :vartype internal_id: str - """ - - _validation = { - "prometheus_query_endpoint": {"readonly": True}, - "internal_id": {"readonly": True}, - } - - _attribute_map = { - "prometheus_query_endpoint": {"key": "prometheusQueryEndpoint", "type": "str"}, - "internal_id": {"key": "internalId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.monitor.v2021_06_03_preview.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.monitor.v2021_06_03_preview.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class AzureMonitorWorkspaceResource(TrackedResource): # pylint: disable=too-many-instance-attributes - """An Azure Monitor Workspace definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.monitor.v2021_06_03_preview.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar account_id: The immutable ID of the Azure Monitor workspace. This property is read-only. - :vartype account_id: str - :ivar metrics: Information about metrics for the Azure Monitor workspace. - :vartype metrics: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceMetrics - :ivar provisioning_state: The provisioning state of the Azure Monitor workspace. Set to - Succeeded if everything is healthy. Known values are: "Creating", "Succeeded", "Deleting", - "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_06_03_preview.models.ProvisioningState - :ivar default_ingestion_settings: The Data Collection Rule and Endpoint used for ingestion by - default. - :vartype default_ingestion_settings: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceDefaultIngestionSettings - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "etag": {"readonly": True}, - "account_id": {"readonly": True}, - "metrics": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "default_ingestion_settings": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "account_id": {"key": "properties.accountId", "type": "str"}, - "metrics": {"key": "properties.metrics", "type": "AzureMonitorWorkspaceMetrics"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "default_ingestion_settings": { - "key": "properties.defaultIngestionSettings", - "type": "AzureMonitorWorkspaceDefaultIngestionSettings", - }, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(tags=tags, location=location, **kwargs) - self.etag = None - self.account_id = None - self.metrics = None - self.provisioning_state = None - self.default_ingestion_settings = None - - -class AzureMonitorWorkspaceResourceForUpdate(_serialization.Model): - """Definition of ARM tracked top level resource properties for update operation. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class AzureMonitorWorkspaceResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: - list[~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AzureMonitorWorkspaceResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AzureMonitorWorkspaceResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AzureMonitorWorkspaceResourceProperties(AzureMonitorWorkspace): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar account_id: The immutable ID of the Azure Monitor workspace. This property is read-only. - :vartype account_id: str - :ivar metrics: Information about metrics for the Azure Monitor workspace. - :vartype metrics: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceMetrics - :ivar provisioning_state: The provisioning state of the Azure Monitor workspace. Set to - Succeeded if everything is healthy. Known values are: "Creating", "Succeeded", "Deleting", - "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_06_03_preview.models.ProvisioningState - :ivar default_ingestion_settings: The Data Collection Rule and Endpoint used for ingestion by - default. - :vartype default_ingestion_settings: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceDefaultIngestionSettings - """ - - _validation = { - "account_id": {"readonly": True}, - "metrics": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "default_ingestion_settings": {"readonly": True}, - } - - _attribute_map = { - "account_id": {"key": "accountId", "type": "str"}, - "metrics": {"key": "metrics", "type": "AzureMonitorWorkspaceMetrics"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "default_ingestion_settings": { - "key": "defaultIngestionSettings", - "type": "AzureMonitorWorkspaceDefaultIngestionSettings", - }, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2021_06_03_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.monitor.v2021_06_03_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2021_06_03_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2021_06_03_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Operation(_serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.monitor.v2021_06_03_preview.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", - and "user,system". - :vartype origin: str or ~azure.mgmt.monitor.v2021_06_03_preview.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. "Internal" - :vartype action_type: str or ~azure.mgmt.monitor.v2021_06_03_preview.models.ActionType - """ - - _validation = { - "name": {"readonly": True}, - "is_data_action": {"readonly": True}, - "origin": {"readonly": True}, - "action_type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "action_type": {"key": "actionType", "type": "str"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.monitor.v2021_06_03_preview.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.is_data_action = None - self.display = display - self.origin = None - self.action_type = None - - -class OperationDisplay(_serialization.Model): - """Localized display information for this particular operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.monitor.v2021_06_03_preview.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2021_06_03_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2021_06_03_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2021_06_03_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2021_06_03_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index c24d09a181f8c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" - - INTERNAL = "Internal" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit - logs UX. Default value is "user,system". - """ - - USER = "user" - SYSTEM = "system" - USER_SYSTEM = "user,system" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state of the Azure Monitor workspace. Set to Succeeded if everything is - healthy. - """ - - CREATING = "Creating" - SUCCEEDED = "Succeeded" - DELETING = "Deleting" - FAILED = "Failed" - CANCELED = "Canceled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/__init__.py deleted file mode 100644 index cc4f2ca90de6c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._azure_monitor_workspaces_operations import AzureMonitorWorkspacesOperations -from ._monitor_operations_operations import MonitorOperationsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureMonitorWorkspacesOperations", - "MonitorOperationsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_azure_monitor_workspaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_azure_monitor_workspaces_operations.py deleted file mode 100644 index 945e7e38b6688..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_azure_monitor_workspaces_operations.py +++ /dev/null @@ -1,865 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/accounts") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, azure_monitor_workspace_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "azureMonitorWorkspaceName": _SERIALIZER.url( - "azure_monitor_workspace_name", azure_monitor_workspace_name, "str", pattern=r"^(?!-)[a-zA-Z0-9-]+[^-]$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, azure_monitor_workspace_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "azureMonitorWorkspaceName": _SERIALIZER.url( - "azure_monitor_workspace_name", azure_monitor_workspace_name, "str", pattern=r"^(?!-)[a-zA-Z0-9-]+[^-]$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, azure_monitor_workspace_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "azureMonitorWorkspaceName": _SERIALIZER.url( - "azure_monitor_workspace_name", azure_monitor_workspace_name, "str", pattern=r"^(?!-)[a-zA-Z0-9-]+[^-]$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, azure_monitor_workspace_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "azureMonitorWorkspaceName": _SERIALIZER.url( - "azure_monitor_workspace_name", azure_monitor_workspace_name, "str", pattern=r"^(?!-)[a-zA-Z0-9-]+[^-]$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AzureMonitorWorkspacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_06_03_preview.MonitorManagementClient`'s - :attr:`azure_monitor_workspaces` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AzureMonitorWorkspaceResource"]: - """Lists all workspaces in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorWorkspaceResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.AzureMonitorWorkspaceResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorWorkspaceResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AzureMonitorWorkspaceResource"]: - """Lists all workspaces in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorWorkspaceResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.AzureMonitorWorkspaceResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorWorkspaceResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/accounts"} - - @distributed_trace - def get( - self, resource_group_name: str, azure_monitor_workspace_name: str, **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Returns the specific Azure Monitor workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.AzureMonitorWorkspaceResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } - - @overload - def create( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: _models.AzureMonitorWorkspaceResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Create or update a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: Properties that need to be specified to create a new - workspace. Required. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Create or update a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: Properties that need to be specified to create a new - workspace. Required. - :type azure_monitor_workspace_properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Union[_models.AzureMonitorWorkspaceResource, IO], - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Create or update a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: Properties that need to be specified to create a new - workspace. Is either a AzureMonitorWorkspaceResource type or a IO type. Required. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorWorkspaceResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_workspace_properties, (IO, bytes)): - _content = azure_monitor_workspace_properties - else: - _json = self._serialize.body(azure_monitor_workspace_properties, "AzureMonitorWorkspaceResource") - - request = build_create_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } - - @overload - def update( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Optional[_models.AzureMonitorWorkspaceResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Updates part of a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: The payload. Default value is None. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Updates part of a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: The payload. Default value is None. - :type azure_monitor_workspace_properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - azure_monitor_workspace_name: str, - azure_monitor_workspace_properties: Optional[Union[_models.AzureMonitorWorkspaceResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.AzureMonitorWorkspaceResource: - """Updates part of a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :param azure_monitor_workspace_properties: The payload. Is either a - AzureMonitorWorkspaceResourceForUpdate type or a IO type. Default value is None. - :type azure_monitor_workspace_properties: - ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorWorkspaceResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_06_03_preview.models.AzureMonitorWorkspaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorWorkspaceResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_workspace_properties, (IO, bytes)): - _content = azure_monitor_workspace_properties - else: - if azure_monitor_workspace_properties is not None: - _json = self._serialize.body( - azure_monitor_workspace_properties, "AzureMonitorWorkspaceResourceForUpdate" - ) - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorWorkspaceResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, azure_monitor_workspace_name: str, **kwargs: Any - ) -> None: - """Delete a workspace. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param azure_monitor_workspace_name: The name of the Azure Monitor workspace. The name is case - insensitive. Required. - :type azure_monitor_workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - azure_monitor_workspace_name=azure_monitor_workspace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_monitor_operations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_monitor_operations_operations.py deleted file mode 100644 index f91fec9a1f9ee..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_monitor_operations_operations.py +++ /dev/null @@ -1,155 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Monitor/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class MonitorOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_06_03_preview.MonitorManagementClient`'s - :attr:`monitor_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists available Operations for this Resource Provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_06_03_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-03-preview")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Monitor/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_06_03_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_configuration.py deleted file mode 100644 index 746cd69c06e9f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_metadata.json deleted file mode 100644 index 9c78561f0f7e4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2021-07-01-preview", - "total_api_version_list": ["2021-07-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "private_link_scopes": "PrivateLinkScopesOperations", - "private_link_scope_operation_status": "PrivateLinkScopeOperationStatusOperations", - "private_link_resources": "PrivateLinkResourcesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "private_link_scoped_resources": "PrivateLinkScopedResourcesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_monitor_management_client.py deleted file mode 100644 index e443fc8f494f9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - PrivateLinkScopeOperationStatusOperations, - PrivateLinkScopedResourcesOperations, - PrivateLinkScopesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: - azure.mgmt.monitor.v2021_07_01_preview.operations.PrivateLinkScopesOperations - :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations - :vartype private_link_scope_operation_status: - azure.mgmt.monitor.v2021_07_01_preview.operations.PrivateLinkScopeOperationStatusOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.monitor.v2021_07_01_preview.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.monitor.v2021_07_01_preview.operations.PrivateEndpointConnectionsOperations - :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations - :vartype private_link_scoped_resources: - azure.mgmt.monitor.v2021_07_01_preview.operations.PrivateLinkScopedResourcesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.private_link_scopes = PrivateLinkScopesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_configuration.py deleted file mode 100644 index e8bedc02dd43c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 6480f4066fba2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - PrivateEndpointConnectionsOperations, - PrivateLinkResourcesOperations, - PrivateLinkScopeOperationStatusOperations, - PrivateLinkScopedResourcesOperations, - PrivateLinkScopesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: - azure.mgmt.monitor.v2021_07_01_preview.aio.operations.PrivateLinkScopesOperations - :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations - :vartype private_link_scope_operation_status: - azure.mgmt.monitor.v2021_07_01_preview.aio.operations.PrivateLinkScopeOperationStatusOperations - :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - azure.mgmt.monitor.v2021_07_01_preview.aio.operations.PrivateLinkResourcesOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.monitor.v2021_07_01_preview.aio.operations.PrivateEndpointConnectionsOperations - :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations - :vartype private_link_scoped_resources: - azure.mgmt.monitor.v2021_07_01_preview.aio.operations.PrivateLinkScopedResourcesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.private_link_scopes = PrivateLinkScopesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/__init__.py deleted file mode 100644 index 1f7c00746a8dc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._private_link_scopes_operations import PrivateLinkScopesOperations -from ._private_link_scope_operation_status_operations import PrivateLinkScopeOperationStatusOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PrivateLinkScopesOperations", - "PrivateLinkScopeOperationStatusOperations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "PrivateLinkScopedResourcesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 6e2eb36a258f1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,548 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_private_link_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.aio.MonitorManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace_async - async def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnectionListResult: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnectionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_resources_operations.py deleted file mode 100644 index a5d13a354e31d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.aio.MonitorManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scope_operation_status_operations.py deleted file mode 100644 index 6c09e972797fa..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scope_operation_status_operations.py +++ /dev/null @@ -1,115 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_scope_operation_status_operations import build_get_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkScopeOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.aio.MonitorManagementClient`'s - :attr:`private_link_scope_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: - """Get the status of an azure asynchronous operation associated with a private link scope - operation. - - :param async_operation_id: The operation Id. Required. - :type async_operation_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - async_operation_id=async_operation_id, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scoped_resources_operations.py deleted file mode 100644 index 12fe7bf5c75ce..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scoped_resources_operations.py +++ /dev/null @@ -1,579 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_scoped_resources_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_private_link_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkScopedResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.aio.MonitorManagementClient`'s - :attr:`private_link_scoped_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: - """Gets a scoped resource in a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopedResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> Optional[_models.ScopedResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ScopedResource]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScopedResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: _models.ScopedResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Is either a ScopedResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopedResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ScopedResource"]: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scopes_operations.py deleted file mode 100644 index 298dbf7c95d78..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/aio/operations/_private_link_scopes_operations.py +++ /dev/null @@ -1,718 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._private_link_scopes_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_tags_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateLinkScopesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.aio.MonitorManagementClient`'s - :attr:`private_link_scopes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Returns a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a - IO type. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_private_link_scope_payload, (IO, bytes)): - _content = azure_monitor_private_link_scope_payload - else: - _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - async def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: _models.TagsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2021_07_01_preview.models.TagsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: Union[_models.TagsResource, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a TagsResource type or a IO type. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2021_07_01_preview.models.TagsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_link_scope_tags, (IO, bytes)): - _content = private_link_scope_tags - else: - _json = self._serialize.body(private_link_scope_tags, "TagsResource") - - request = build_update_tags_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update_tags.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/__init__.py deleted file mode 100644 index c4ffb95899070..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AccessModeSettings -from ._models_py3 import AccessModeSettingsExclusion -from ._models_py3 import AzureMonitorPrivateLinkScope -from ._models_py3 import AzureMonitorPrivateLinkScopeListResult -from ._models_py3 import DefaultErrorResponse -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import OperationStatus -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionListResult -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import ProxyResource -from ._models_py3 import Resource -from ._models_py3 import ScopedResource -from ._models_py3 import ScopedResourceListResult -from ._models_py3 import SystemData -from ._models_py3 import TagsResource -from ._models_py3 import TrackedResource - -from ._monitor_management_client_enums import AccessMode -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import PrivateEndpointConnectionProvisioningState -from ._monitor_management_client_enums import PrivateEndpointServiceConnectionStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessModeSettings", - "AccessModeSettingsExclusion", - "AzureMonitorPrivateLinkScope", - "AzureMonitorPrivateLinkScopeListResult", - "DefaultErrorResponse", - "ErrorAdditionalInfo", - "ErrorDetail", - "OperationStatus", - "PrivateEndpoint", - "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", - "PrivateLinkResource", - "PrivateLinkResourceListResult", - "PrivateLinkServiceConnectionState", - "ProxyResource", - "Resource", - "ScopedResource", - "ScopedResourceListResult", - "SystemData", - "TagsResource", - "TrackedResource", - "AccessMode", - "CreatedByType", - "PrivateEndpointConnectionProvisioningState", - "PrivateEndpointServiceConnectionStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_models_py3.py deleted file mode 100644 index 9ab87ce13af65..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_models_py3.py +++ /dev/null @@ -1,909 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AccessModeSettings(_serialization.Model): - """Properties that define the scope private link mode settings. - - All required parameters must be populated in order to send to Azure. - - :ivar query_access_mode: Specifies the default access mode of queries through associated - private endpoints in scope. If not specified default value is 'Open'. You can override this - default setting for a specific private endpoint connection by adding an exclusion in the - 'exclusions' array. Required. Known values are: "Open" and "PrivateOnly". - :vartype query_access_mode: str or ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - :ivar ingestion_access_mode: Specifies the default access mode of ingestion through associated - private endpoints in scope. If not specified default value is 'Open'. You can override this - default setting for a specific private endpoint connection by adding an exclusion in the - 'exclusions' array. Required. Known values are: "Open" and "PrivateOnly". - :vartype ingestion_access_mode: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - :ivar exclusions: List of exclusions that override the default access mode settings for - specific private endpoint connections. - :vartype exclusions: - list[~azure.mgmt.monitor.v2021_07_01_preview.models.AccessModeSettingsExclusion] - """ - - _validation = { - "query_access_mode": {"required": True}, - "ingestion_access_mode": {"required": True}, - } - - _attribute_map = { - "query_access_mode": {"key": "queryAccessMode", "type": "str"}, - "ingestion_access_mode": {"key": "ingestionAccessMode", "type": "str"}, - "exclusions": {"key": "exclusions", "type": "[AccessModeSettingsExclusion]"}, - } - - def __init__( - self, - *, - query_access_mode: Union[str, "_models.AccessMode"], - ingestion_access_mode: Union[str, "_models.AccessMode"], - exclusions: Optional[List["_models.AccessModeSettingsExclusion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword query_access_mode: Specifies the default access mode of queries through associated - private endpoints in scope. If not specified default value is 'Open'. You can override this - default setting for a specific private endpoint connection by adding an exclusion in the - 'exclusions' array. Required. Known values are: "Open" and "PrivateOnly". - :paramtype query_access_mode: str or ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - :keyword ingestion_access_mode: Specifies the default access mode of ingestion through - associated private endpoints in scope. If not specified default value is 'Open'. You can - override this default setting for a specific private endpoint connection by adding an exclusion - in the 'exclusions' array. Required. Known values are: "Open" and "PrivateOnly". - :paramtype ingestion_access_mode: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - :keyword exclusions: List of exclusions that override the default access mode settings for - specific private endpoint connections. - :paramtype exclusions: - list[~azure.mgmt.monitor.v2021_07_01_preview.models.AccessModeSettingsExclusion] - """ - super().__init__(**kwargs) - self.query_access_mode = query_access_mode - self.ingestion_access_mode = ingestion_access_mode - self.exclusions = exclusions - - -class AccessModeSettingsExclusion(_serialization.Model): - """Properties that define the scope private link mode settings exclusion item. This setting - applies to a specific private endpoint connection and overrides the default settings for that - private endpoint connection. - - :ivar private_endpoint_connection_name: The private endpoint connection name associated to the - private endpoint on which we want to apply the specific access mode settings. - :vartype private_endpoint_connection_name: str - :ivar query_access_mode: Specifies the access mode of queries through the specified private - endpoint connection in the exclusion. Known values are: "Open" and "PrivateOnly". - :vartype query_access_mode: str or ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - :ivar ingestion_access_mode: Specifies the access mode of ingestion through the specified - private endpoint connection in the exclusion. Known values are: "Open" and "PrivateOnly". - :vartype ingestion_access_mode: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - """ - - _attribute_map = { - "private_endpoint_connection_name": {"key": "privateEndpointConnectionName", "type": "str"}, - "query_access_mode": {"key": "queryAccessMode", "type": "str"}, - "ingestion_access_mode": {"key": "ingestionAccessMode", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint_connection_name: Optional[str] = None, - query_access_mode: Optional[Union[str, "_models.AccessMode"]] = None, - ingestion_access_mode: Optional[Union[str, "_models.AccessMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint_connection_name: The private endpoint connection name associated to - the private endpoint on which we want to apply the specific access mode settings. - :paramtype private_endpoint_connection_name: str - :keyword query_access_mode: Specifies the access mode of queries through the specified private - endpoint connection in the exclusion. Known values are: "Open" and "PrivateOnly". - :paramtype query_access_mode: str or ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - :keyword ingestion_access_mode: Specifies the access mode of ingestion through the specified - private endpoint connection in the exclusion. Known values are: "Open" and "PrivateOnly". - :paramtype ingestion_access_mode: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessMode - """ - super().__init__(**kwargs) - self.private_endpoint_connection_name = private_endpoint_connection_name - self.query_access_mode = query_access_mode - self.ingestion_access_mode = ingestion_access_mode - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - - -class AzureMonitorPrivateLinkScope(TrackedResource): - """An Azure Monitor PrivateLinkScope definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar system_data: System data. - :vartype system_data: ~azure.mgmt.monitor.v2021_07_01_preview.models.SystemData - :ivar provisioning_state: 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. - :vartype provisioning_state: str - :ivar private_endpoint_connections: List of private endpoint connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - :ivar access_mode_settings: Access mode settings. Required. - :vartype access_mode_settings: - ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessModeSettings - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "access_mode_settings": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnection]", - }, - "access_mode_settings": {"key": "properties.accessModeSettings", "type": "AccessModeSettings"}, - } - - def __init__( - self, - *, - location: str, - access_mode_settings: "_models.AccessModeSettings", - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword access_mode_settings: Access mode settings. Required. - :paramtype access_mode_settings: - ~azure.mgmt.monitor.v2021_07_01_preview.models.AccessModeSettings - """ - super().__init__(tags=tags, location=location, **kwargs) - self.system_data = None - self.provisioning_state = None - self.private_endpoint_connections = None - self.access_mode_settings = access_mode_settings - - -class AzureMonitorPrivateLinkScopeListResult(_serialization.Model): - """Describes the list of Azure Monitor PrivateLinkScope resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: List of Azure Monitor PrivateLinkScope definitions. Required. - :vartype value: - list[~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope] - :ivar next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if - too many PrivateLinkScopes where returned in the result set. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AzureMonitorPrivateLinkScope]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AzureMonitorPrivateLinkScope"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of Azure Monitor PrivateLinkScope definitions. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope] - :keyword next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions - if too many PrivateLinkScopes where returned in the result set. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DefaultErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2021_07_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2021_07_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2021_07_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.monitor.v2021_07_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class OperationStatus(_serialization.Model): - """The status of operation. - - :ivar id: The operation Id. - :vartype id: str - :ivar name: The operation name. - :vartype name: str - :ivar start_time: Start time of the job in standard ISO8601 format. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the job in standard ISO8601 format. - :vartype end_time: ~datetime.datetime - :ivar status: The status of the operation. - :vartype status: str - :ivar error: The error detail of the operation if any. - :vartype error: ~azure.mgmt.monitor.v2021_07_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "status": {"key": "status", "type": "str"}, - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - start_time: Optional[datetime.datetime] = None, - end_time: Optional[datetime.datetime] = None, - status: Optional[str] = None, - error: Optional["_models.ErrorDetail"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The operation Id. - :paramtype id: str - :keyword name: The operation name. - :paramtype name: str - :keyword start_time: Start time of the job in standard ISO8601 format. - :paramtype start_time: ~datetime.datetime - :keyword end_time: End time of the job in standard ISO8601 format. - :paramtype end_time: ~datetime.datetime - :keyword status: The status of the operation. - :paramtype status: str - :keyword error: The error detail of the operation if any. - :paramtype error: ~azure.mgmt.monitor.v2021_07_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.start_time = start_time - self.end_time = end_time - self.status = status - self.error = error - - -class PrivateEndpoint(_serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(Resource): - """The Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between service consumer and provider. - :vartype private_link_service_connection_state: - ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpoint - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :paramtype private_link_service_connection_state: - ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """List of private endpoint connection associated with the specified storage account. - - :ivar value: Array of private endpoint connections. - :vartype value: list[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private endpoint connections. - :paramtype value: - list[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource Private link DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_id": {"key": "properties.groupId", "type": "str"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource Private link DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required = actions_required - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class ScopedResource(ProxyResource): - """A private link scoped resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: System data. - :vartype system_data: ~azure.mgmt.monitor.v2021_07_01_preview.models.SystemData - :ivar linked_resource_id: The resource id of the scoped Azure monitor resource. - :vartype linked_resource_id: str - :ivar provisioning_state: State of the private endpoint connection. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "linked_resource_id": {"key": "properties.linkedResourceId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, *, linked_resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword linked_resource_id: The resource id of the scoped Azure monitor resource. - :paramtype linked_resource_id: str - """ - super().__init__(**kwargs) - self.system_data = None - self.linked_resource_id = linked_resource_id - self.provisioning_state = None - - -class ScopedResourceListResult(_serialization.Model): - """A list of scoped resources in a private link scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ScopedResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2021_07_01_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2021_07_01_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2021_07_01_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TagsResource(_serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on a - PrivateLinkScope instance. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 2d31a600c79b9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Access mode types.""" - - OPEN = "Open" - PRIVATE_ONLY = "PrivateOnly" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state.""" - - SUCCEEDED = "Succeeded" - CREATING = "Creating" - DELETING = "Deleting" - FAILED = "Failed" - - -class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status.""" - - PENDING = "Pending" - APPROVED = "Approved" - REJECTED = "Rejected" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/__init__.py deleted file mode 100644 index 1f7c00746a8dc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._private_link_scopes_operations import PrivateLinkScopesOperations -from ._private_link_scope_operation_status_operations import PrivateLinkScopeOperationStatusOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PrivateLinkScopesOperations", - "PrivateLinkScopeOperationStatusOperations", - "PrivateLinkResourcesOperations", - "PrivateEndpointConnectionsOperations", - "PrivateLinkScopedResourcesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index bf43481d3794a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,702 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_private_link_scope_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.MonitorManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "PrivateEndpointConnection") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def begin_delete( - self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnectionListResult: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateEndpointConnectionListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_resources_operations.py deleted file mode 100644 index 834b2647e84c0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,254 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_private_link_scope_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, scope_name: str, group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "groupName": _SERIALIZER.url("group_name", group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.MonitorManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources" - } - - @distributed_trace - def get( - self, resource_group_name: str, scope_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scope_operation_status_operations.py deleted file mode 100644 index 8954342765bef..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scope_operation_status_operations.py +++ /dev/null @@ -1,151 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - async_operation_id: str, resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkScopeOperationStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.MonitorManagementClient`'s - :attr:`private_link_scope_operation_status` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) -> _models.OperationStatus: - """Get the status of an azure asynchronous operation associated with a private link scope - operation. - - :param async_operation_id: The operation Id. Required. - :type async_operation_id: str - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationStatus or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.OperationStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) - - request = build_get_request( - async_operation_id=async_operation_id, - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OperationStatus", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scoped_resources_operations.py deleted file mode 100644 index f970d2f14190d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scoped_resources_operations.py +++ /dev/null @@ -1,712 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, scope_name: str, name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_private_link_scope_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkScopedResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.MonitorManagementClient`'s - :attr:`private_link_scoped_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> _models.ScopedResource: - """Gets a scoped resource in a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScopedResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - def _create_or_update_initial( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> Optional[_models.ScopedResource]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ScopedResource]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScopedResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_or_update_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScopedResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: _models.ScopedResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - scope_name: str, - name: str, - parameters: Union[_models.ScopedResource, IO], - **kwargs: Any - ) -> LROPoller[_models.ScopedResource]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :param parameters: Is either a ScopedResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either ScopedResource or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopedResource", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace - def begin_delete(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param name: The name of the scoped resource object. Required. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - name=name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" - } - - @distributed_trace - def list_by_private_link_scope( - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> Iterable["_models.ScopedResource"]: - """Gets all private endpoint connections on a private link scope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_07_01_preview.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_private_link_scope_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_private_link_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_private_link_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scopes_operations.py deleted file mode 100644 index 04fb65892d855..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/operations/_private_link_scopes_operations.py +++ /dev/null @@ -1,899 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_tags_request( - resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkScopesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_07_01_preview.MonitorManagementClient`'s - :attr:`private_link_scopes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AzureMonitorPrivateLinkScope"]: - """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScope or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, scope_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace - def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - scope_name=scope_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @distributed_trace - def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _models.AzureMonitorPrivateLinkScope: - """Returns a Azure Monitor PrivateLinkScope. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Required. - :type azure_monitor_private_link_scope_payload: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - scope_name: str, - azure_monitor_private_link_scope_payload: Union[_models.AzureMonitorPrivateLinkScope, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different - value for InstrumentationKey nor AppId in the Put operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a - IO type. Required. - :type azure_monitor_private_link_scope_payload: - ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(azure_monitor_private_link_scope_payload, (IO, bytes)): - _content = azure_monitor_private_link_scope_payload - else: - _json = self._serialize.body(azure_monitor_private_link_scope_payload, "AzureMonitorPrivateLinkScope") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } - - @overload - def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: _models.TagsResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2021_07_01_preview.models.TagsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Required. - :type private_link_scope_tags: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update_tags( - self, - resource_group_name: str, - scope_name: str, - private_link_scope_tags: Union[_models.TagsResource, IO], - **kwargs: Any - ) -> _models.AzureMonitorPrivateLinkScope: - """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. - :type scope_name: str - :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a TagsResource type or a IO type. Required. - :type private_link_scope_tags: ~azure.mgmt.monitor.v2021_07_01_preview.models.TagsResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorPrivateLinkScope or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_07_01_preview.models.AzureMonitorPrivateLinkScope - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_link_scope_tags, (IO, bytes)): - _content = private_link_scope_tags - else: - _json = self._serialize.body(private_link_scope_tags, "TagsResource") - - request = build_update_tags_request( - resource_group_name=resource_group_name, - scope_name=scope_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update_tags.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update_tags.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_07_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py deleted file mode 100644 index cacdad67be60c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json deleted file mode 100644 index 58ac7be972a99..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2021-09-01", - "total_api_version_list": ["2021-09-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py deleted file mode 100644 index 2ef72036c28ae..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2021_09_01.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py deleted file mode 100644 index cbebb0cdaa7c0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-09-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py deleted file mode 100644 index 91cba56ea2234..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2021_09_01.aio.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index a25f3a940aeb6..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,1649 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_notifications_at_action_group_resource_level_request, - build_create_notifications_at_resource_group_level_request, - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_get_test_notifications_at_action_group_resource_level_request, - build_get_test_notifications_at_resource_group_level_request, - build_get_test_notifications_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_post_test_notifications_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_09_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - async def _post_test_notifications_initial( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_post_test_notifications_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._post_test_notifications_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_test_notifications_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - @overload - async def begin_post_test_notifications( - self, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_post_test_notifications( - self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_post_test_notifications( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._post_test_notifications_initial( - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_post_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - async def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_resource_group_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @overload - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_notifications_at_resource_group_level_initial( - resource_group_name=resource_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - async def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_action_group_resource_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @overload - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_notifications_at_action_group_resource_level_initial( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @distributed_trace_async - async def get_test_notifications( - self, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_request( - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace_async - async def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace_async - async def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2021_09_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2021_09_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py deleted file mode 100644 index b1dac637c4030..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionDetail -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ArmRoleReceiver -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import AzureResource -from ._models_py3 import Context -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import EventHubReceiver -from ._models_py3 import ItsmReceiver -from ._models_py3 import LogicAppReceiver -from ._models_py3 import NotificationRequestBody -from ._models_py3 import SmsReceiver -from ._models_py3 import TestNotificationDetailsResponse -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionDetail", - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ArmRoleReceiver", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "AzureResource", - "Context", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "EventHubReceiver", - "ItsmReceiver", - "LogicAppReceiver", - "NotificationRequestBody", - "SmsReceiver", - "TestNotificationDetailsResponse", - "VoiceReceiver", - "WebhookReceiver", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py deleted file mode 100644 index 3894b56cc389f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py +++ /dev/null @@ -1,1240 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionDetail(_serialization.Model): - """The action detail. - - :ivar mechanism_type: The mechanism type. - :vartype mechanism_type: str - :ivar name: The name of the action. - :vartype name: str - :ivar status: The status of the action. - :vartype status: str - :ivar sub_state: The substatus of the action. - :vartype sub_state: str - :ivar send_time: The send time. - :vartype send_time: str - :ivar detail: The detail of the friendly error message. - :vartype detail: str - """ - - _attribute_map = { - "mechanism_type": {"key": "MechanismType", "type": "str"}, - "name": {"key": "Name", "type": "str"}, - "status": {"key": "Status", "type": "str"}, - "sub_state": {"key": "SubState", "type": "str"}, - "send_time": {"key": "SendTime", "type": "str"}, - "detail": {"key": "Detail", "type": "str"}, - } - - def __init__( - self, - *, - mechanism_type: Optional[str] = None, - name: Optional[str] = None, - status: Optional[str] = None, - sub_state: Optional[str] = None, - send_time: Optional[str] = None, - detail: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword mechanism_type: The mechanism type. - :paramtype mechanism_type: str - :keyword name: The name of the action. - :paramtype name: str - :keyword status: The status of the action. - :paramtype status: str - :keyword sub_state: The substatus of the action. - :paramtype sub_state: str - :keyword send_time: The send time. - :paramtype send_time: str - :keyword detail: The detail of the friendly error message. - :paramtype detail: str - """ - super().__init__(**kwargs) - self.mechanism_type = mechanism_type - self.name = name - self.status = status - self.sub_state = sub_state - self.send_time = send_time - self.detail = detail - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class AzureResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EventHubReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EventHubReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class ArmRoleReceiver(_serialization.Model): - """An arm role receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the arm role receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar role_id: The arm role id. Required. - :vartype role_id: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "role_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "role_id": {"key": "roleId", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the arm role receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword role_id: The arm role id. Required. - :paramtype role_id: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.role_id = role_id - self.use_common_alert_schema = use_common_alert_schema - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - self.use_common_alert_schema = use_common_alert_schema - - -class Context(_serialization.Model): - """The context info. - - :ivar notification_source: The source of the notification request. - :vartype notification_source: str - :ivar context_type: The context id type. - :vartype context_type: str - """ - - _attribute_map = { - "notification_source": {"key": "notificationSource", "type": "str"}, - "context_type": {"key": "contextType", "type": "str"}, - } - - def __init__( - self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword notification_source: The source of the notification request. - :paramtype notification_source: str - :keyword context_type: The context id type. - :paramtype context_type: str - """ - super().__init__(**kwargs) - self.notification_source = notification_source - self.context_type = context_type - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2021_09_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.use_common_alert_schema = use_common_alert_schema - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class EventHubReceiver(_serialization.Model): - """An Event hub receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar event_hub_name_space: The Event Hub namespace. Required. - :vartype event_hub_name_space: str - :ivar event_hub_name: The name of the specific Event Hub queue. Required. - :vartype event_hub_name: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar tenant_id: The tenant Id for the subscription containing this event hub. - :vartype tenant_id: str - :ivar subscription_id: The Id for the subscription containing this event hub. Required. - :vartype subscription_id: str - """ - - _validation = { - "name": {"required": True}, - "event_hub_name_space": {"required": True}, - "event_hub_name": {"required": True}, - "subscription_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, - "event_hub_name": {"key": "eventHubName", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - event_hub_name_space: str, - event_hub_name: str, - subscription_id: str, - use_common_alert_schema: bool = False, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword event_hub_name_space: The Event Hub namespace. Required. - :paramtype event_hub_name_space: str - :keyword event_hub_name: The name of the specific Event Hub queue. Required. - :paramtype event_hub_name: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword tenant_id: The tenant Id for the subscription containing this event hub. - :paramtype tenant_id: str - :keyword subscription_id: The Id for the subscription containing this event hub. Required. - :paramtype subscription_id: str - """ - super().__init__(**kwargs) - self.name = name - self.event_hub_name_space = event_hub_name_space - self.event_hub_name = event_hub_name - self.use_common_alert_schema = use_common_alert_schema - self.tenant_id = tenant_id - self.subscription_id = subscription_id - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - self.use_common_alert_schema = use_common_alert_schema - - -class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The request body which contain contact detail metadata. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :vartype alert_type: str - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EventHubReceiver] - """ - - _validation = { - "alert_type": {"required": True, "max_length": 30}, - } - - _attribute_map = { - "alert_type": {"key": "alertType", "type": "str"}, - "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, - "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - alert_type: str, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :paramtype alert_type: str - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2021_09_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2021_09_01.models.EventHubReceiver] - """ - super().__init__(**kwargs) - self.alert_type = alert_type - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2021_09_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class TestNotificationDetailsResponse(_serialization.Model): - """The details of the test notification results. - - All required parameters must be populated in order to send to Azure. - - :ivar context: The context info. - :vartype context: ~azure.mgmt.monitor.v2021_09_01.models.Context - :ivar state: The overall state. Required. - :vartype state: str - :ivar completed_time: The completed time. - :vartype completed_time: str - :ivar created_time: The created time. - :vartype created_time: str - :ivar action_details: The list of action detail. - :vartype action_details: list[~azure.mgmt.monitor.v2021_09_01.models.ActionDetail] - """ - - _validation = { - "state": {"required": True}, - } - - _attribute_map = { - "context": {"key": "context", "type": "Context"}, - "state": {"key": "state", "type": "str"}, - "completed_time": {"key": "completedTime", "type": "str"}, - "created_time": {"key": "createdTime", "type": "str"}, - "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, - } - - def __init__( - self, - *, - state: str, - context: Optional["_models.Context"] = None, - completed_time: Optional[str] = None, - created_time: Optional[str] = None, - action_details: Optional[List["_models.ActionDetail"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context: The context info. - :paramtype context: ~azure.mgmt.monitor.v2021_09_01.models.Context - :keyword state: The overall state. Required. - :paramtype state: str - :keyword completed_time: The completed time. - :paramtype completed_time: str - :keyword created_time: The created time. - :paramtype created_time: str - :keyword action_details: The list of action detail. - :paramtype action_details: list[~azure.mgmt.monitor.v2021_09_01.models.ActionDetail] - """ - super().__init__(**kwargs) - self.context = context - self.state = state - self.completed_time = completed_time - self.created_time = created_time - self.action_details = action_details - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar use_aad_auth: Indicates whether or not use AAD authentication. - :vartype use_aad_auth: bool - :ivar object_id: Indicates the webhook app object Id for aad auth. - :vartype object_id: str - :ivar identifier_uri: Indicates the identifier uri for aad auth. - :vartype identifier_uri: str - :ivar tenant_id: Indicates the tenant id for aad auth. - :vartype tenant_id: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, - "object_id": {"key": "objectId", "type": "str"}, - "identifier_uri": {"key": "identifierUri", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - service_uri: str, - use_common_alert_schema: bool = False, - use_aad_auth: bool = False, - object_id: Optional[str] = None, - identifier_uri: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword use_aad_auth: Indicates whether or not use AAD authentication. - :paramtype use_aad_auth: bool - :keyword object_id: Indicates the webhook app object Id for aad auth. - :paramtype object_id: str - :keyword identifier_uri: Indicates the identifier uri for aad auth. - :paramtype identifier_uri: str - :keyword tenant_id: Indicates the tenant id for aad auth. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - self.use_aad_auth = use_aad_auth - self.object_id = object_id - self.identifier_uri = identifier_uri - self.tenant_id = tenant_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 2502d854d1869..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py deleted file mode 100644 index 1d0a98482f434..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,2058 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_notifications_at_resource_group_level_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_request(notification_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_at_resource_group_level_request( # pylint: disable=name-too-long - resource_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long - resource_group_name: str, action_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2021_09_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - def _post_test_notifications_initial( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_post_test_notifications_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._post_test_notifications_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_test_notifications_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - @overload - def begin_post_test_notifications( - self, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_post_test_notifications( - self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_post_test_notifications( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._post_test_notifications_initial( - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_post_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_resource_group_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @overload - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_notifications_at_resource_group_level_initial( - resource_group_name=resource_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_action_group_resource_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @overload - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2021_09_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_notifications_at_action_group_resource_level_initial( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @distributed_trace - def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_request( - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace - def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace - def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2021_09_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2021_09_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2021_09_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2021_09_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py deleted file mode 100644 index 9cefea7b878c0..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-09-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json deleted file mode 100644 index dd5ef3887f248..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2021-09-01-preview", - "total_api_version_list": ["2021-09-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "data_collection_endpoints": "DataCollectionEndpointsOperations", - "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", - "data_collection_rules": "DataCollectionRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py deleted file mode 100644 index 41cd396218239..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - DataCollectionEndpointsOperations, - DataCollectionRuleAssociationsOperations, - DataCollectionRulesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: - azure.mgmt.monitor.v2022_02_01_preview.operations.DataCollectionEndpointsOperations - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2022_02_01_preview.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2022_02_01_preview.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py deleted file mode 100644 index 8213230543138..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-09-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 2ff8b450311bb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - DataCollectionEndpointsOperations, - DataCollectionRuleAssociationsOperations, - DataCollectionRulesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: - azure.mgmt.monitor.v2022_02_01_preview.aio.operations.DataCollectionEndpointsOperations - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2022_02_01_preview.aio.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2022_02_01_preview.aio.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py deleted file mode 100644 index 842046dd09e5f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._data_collection_endpoints_operations import DataCollectionEndpointsOperations -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataCollectionEndpointsOperations", - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py deleted file mode 100644 index eaae30c3bbd24..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_endpoints_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_02_01_preview.aio.MonitorManagementClient`'s - :attr:`data_collection_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified resource group. - - Lists all data collection endpoints in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified subscription. - - Lists all data collection endpoints in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Returns the specified data collection endpoint. - - Returns the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.DataCollectionEndpointResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionEndpointResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection endpoint. - - Deletes a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index f6127e5cd6bcd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,635 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rule_associations_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_data_collection_endpoint_request, - build_list_by_resource_request, - build_list_by_rule_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_02_01_preview.aio.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace - def list_by_data_collection_endpoint( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection endpoint. - - Lists associations for the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_data_collection_endpoint_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_data_collection_endpoint.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_data_collection_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations" - } - - @distributed_trace_async - async def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py deleted file mode 100644 index 59b8c8bc1018d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rules_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_02_01_preview.aio.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py deleted file mode 100644 index f754863918953..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py +++ /dev/null @@ -1,149 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AzureMonitorMetricsDestination -from ._models_py3 import ColumnDefinition -from ._models_py3 import ConfigurationAccessEndpointSpec -from ._models_py3 import DataCollectionEndpoint -from ._models_py3 import DataCollectionEndpointConfigurationAccess -from ._models_py3 import DataCollectionEndpointLogsIngestion -from ._models_py3 import DataCollectionEndpointNetworkAcls -from ._models_py3 import DataCollectionEndpointResource -from ._models_py3 import DataCollectionEndpointResourceListResult -from ._models_py3 import DataCollectionEndpointResourceProperties -from ._models_py3 import DataCollectionEndpointResourceSystemData -from ._models_py3 import DataCollectionRule -from ._models_py3 import DataCollectionRuleAssociation -from ._models_py3 import DataCollectionRuleAssociationMetadata -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceSystemData -from ._models_py3 import DataCollectionRuleDataSources -from ._models_py3 import DataCollectionRuleDestinations -from ._models_py3 import DataCollectionRuleMetadata -from ._models_py3 import DataCollectionRuleResource -from ._models_py3 import DataCollectionRuleResourceListResult -from ._models_py3 import DataCollectionRuleResourceProperties -from ._models_py3 import DataCollectionRuleResourceSystemData -from ._models_py3 import DataFlow -from ._models_py3 import DataSourcesSpec -from ._models_py3 import DestinationsSpec -from ._models_py3 import DestinationsSpecAzureMonitorMetrics -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponseCommonV2 -from ._models_py3 import ExtensionDataSource -from ._models_py3 import IisLogsDataSource -from ._models_py3 import LogAnalyticsDestination -from ._models_py3 import LogFileSettings -from ._models_py3 import LogFileSettingsText -from ._models_py3 import LogFileTextSettings -from ._models_py3 import LogFilesDataSource -from ._models_py3 import LogFilesDataSourceSettings -from ._models_py3 import LogsIngestionEndpointSpec -from ._models_py3 import Metadata -from ._models_py3 import NetworkRuleSet -from ._models_py3 import PerfCounterDataSource -from ._models_py3 import ResourceForUpdate -from ._models_py3 import StreamDeclaration -from ._models_py3 import SyslogDataSource -from ._models_py3 import SystemData -from ._models_py3 import WindowsEventLogDataSource - -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import KnownColumnDefinitionType -from ._monitor_management_client_enums import KnownDataCollectionEndpointProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionEndpointResourceKind -from ._monitor_management_client_enums import KnownDataCollectionRuleAssociationProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleResourceKind -from ._monitor_management_client_enums import KnownDataFlowStreams -from ._monitor_management_client_enums import KnownExtensionDataSourceStreams -from ._monitor_management_client_enums import KnownLogFileTextSettingsRecordStartTimestampFormat -from ._monitor_management_client_enums import KnownLogFilesDataSourceFormat -from ._monitor_management_client_enums import KnownPerfCounterDataSourceStreams -from ._monitor_management_client_enums import KnownPublicNetworkAccessOptions -from ._monitor_management_client_enums import KnownSyslogDataSourceFacilityNames -from ._monitor_management_client_enums import KnownSyslogDataSourceLogLevels -from ._monitor_management_client_enums import KnownSyslogDataSourceStreams -from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AzureMonitorMetricsDestination", - "ColumnDefinition", - "ConfigurationAccessEndpointSpec", - "DataCollectionEndpoint", - "DataCollectionEndpointConfigurationAccess", - "DataCollectionEndpointLogsIngestion", - "DataCollectionEndpointNetworkAcls", - "DataCollectionEndpointResource", - "DataCollectionEndpointResourceListResult", - "DataCollectionEndpointResourceProperties", - "DataCollectionEndpointResourceSystemData", - "DataCollectionRule", - "DataCollectionRuleAssociation", - "DataCollectionRuleAssociationMetadata", - "DataCollectionRuleAssociationProxyOnlyResource", - "DataCollectionRuleAssociationProxyOnlyResourceListResult", - "DataCollectionRuleAssociationProxyOnlyResourceProperties", - "DataCollectionRuleAssociationProxyOnlyResourceSystemData", - "DataCollectionRuleDataSources", - "DataCollectionRuleDestinations", - "DataCollectionRuleMetadata", - "DataCollectionRuleResource", - "DataCollectionRuleResourceListResult", - "DataCollectionRuleResourceProperties", - "DataCollectionRuleResourceSystemData", - "DataFlow", - "DataSourcesSpec", - "DestinationsSpec", - "DestinationsSpecAzureMonitorMetrics", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponseCommonV2", - "ExtensionDataSource", - "IisLogsDataSource", - "LogAnalyticsDestination", - "LogFileSettings", - "LogFileSettingsText", - "LogFileTextSettings", - "LogFilesDataSource", - "LogFilesDataSourceSettings", - "LogsIngestionEndpointSpec", - "Metadata", - "NetworkRuleSet", - "PerfCounterDataSource", - "ResourceForUpdate", - "StreamDeclaration", - "SyslogDataSource", - "SystemData", - "WindowsEventLogDataSource", - "CreatedByType", - "KnownColumnDefinitionType", - "KnownDataCollectionEndpointProvisioningState", - "KnownDataCollectionEndpointResourceKind", - "KnownDataCollectionRuleAssociationProvisioningState", - "KnownDataCollectionRuleProvisioningState", - "KnownDataCollectionRuleResourceKind", - "KnownDataFlowStreams", - "KnownExtensionDataSourceStreams", - "KnownLogFileTextSettingsRecordStartTimestampFormat", - "KnownLogFilesDataSourceFormat", - "KnownPerfCounterDataSourceStreams", - "KnownPublicNetworkAccessOptions", - "KnownSyslogDataSourceFacilityNames", - "KnownSyslogDataSourceLogLevels", - "KnownSyslogDataSourceStreams", - "KnownWindowsEventLogDataSourceStreams", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py deleted file mode 100644 index aa859920ff5dd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2429 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class AzureMonitorMetricsDestination(_serialization.Model): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class ColumnDefinition(_serialization.Model): - """Definition of custom data column. - - :ivar name: The name of the column. - :vartype name: str - :ivar type: The type of the column data. Known values are: "string", "int", "long", "real", - "boolean", "datetime", and "dynamic". - :vartype type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownColumnDefinitionType - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.KnownColumnDefinitionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the column. - :paramtype name: str - :keyword type: The type of the column data. Known values are: "string", "int", "long", "real", - "boolean", "datetime", and "dynamic". - :paramtype type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownColumnDefinitionType - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class ConfigurationAccessEndpointSpec(_serialization.Model): - """Definition of the endpoint used for accessing configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpoint(_serialization.Model): - """Definition of data collection endpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by clients to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointLogsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, - "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by clients to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointLogsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - """ - super().__init__(**kwargs) - self.description = description - self.immutable_id = immutable_id - self.configuration_access = configuration_access - self.logs_ingestion = logs_ingestion - self.network_acls = network_acls - self.provisioning_state = None - - -class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec): - """The endpoint used by clients to access their configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class LogsIngestionEndpointSpec(_serialization.Model): - """Definition of the endpoint used for ingesting logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): - """The endpoint used by clients to ingest logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class NetworkRuleSet(_serialization.Model): - """Definition of the network rules. - - :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownPublicNetworkAccessOptions - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class DataCollectionEndpointNetworkAcls(NetworkRuleSet): - """Network access control rules for the endpoints. - - :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownPublicNetworkAccessOptions - """ - super().__init__(public_network_access=public_network_access, **kwargs) - - -class DataCollectionEndpointResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". - :vartype kind: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionEndpointResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResourceSystemData - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by clients to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointLogsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - "location": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionEndpointResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "immutable_id": {"key": "properties.immutableId", "type": "str"}, - "configuration_access": { - "key": "properties.configurationAccess", - "type": "DataCollectionEndpointConfigurationAccess", - }, - "logs_ingestion": {"key": "properties.logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "network_acls": {"key": "properties.networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.KnownDataCollectionEndpointResourceKind"]] = None, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". - :paramtype kind: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionEndpointResourceKind - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by clients to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointLogsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.kind = kind - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.immutable_id = immutable_id - self.configuration_access = configuration_access - self.logs_ingestion = logs_ingestion - self.network_acls = network_acls - self.provisioning_state = None - - -class DataCollectionEndpointResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionEndpointResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by clients to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointLogsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, - "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by clients to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointLogsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - """ - super().__init__( - description=description, - immutable_id=immutable_id, - configuration_access=configuration_access, - logs_ingestion=logs_ingestion, - network_acls=network_acls, - **kwargs - ) - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class DataCollectionEndpointResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataCollectionRule(_serialization.Model): - """Definition of what monitoring data to collect and where that data should be sent. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :vartype data_collection_endpoint_id: str - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleMetadata - :ivar stream_declarations: Declaration of custom streams used in this rule. - :vartype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_02_01_preview.models.StreamDeclaration] - :ivar data_sources: 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. - :vartype data_sources: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "metadata": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleMetadata"}, - "stream_declarations": {"key": "streamDeclarations", "type": "{StreamDeclaration}"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :paramtype data_collection_endpoint_id: str - :keyword stream_declarations: Declaration of custom streams used in this rule. - :paramtype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_02_01_preview.models.StreamDeclaration] - :keyword data_sources: 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. - :paramtype data_sources: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataFlow] - """ - super().__init__(**kwargs) - self.description = description - self.immutable_id = None - self.data_collection_endpoint_id = data_collection_endpoint_id - self.metadata = None - self.stream_declarations = stream_declarations - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleAssociation(_serialization.Model): - """Definition of association of a data collection rule with a monitored Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - :ivar metadata: Metadata about the resource. - :vartype metadata: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationMetadata - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleAssociationMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__(**kwargs) - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.data_collection_endpoint_id = data_collection_endpoint_id - self.provisioning_state = None - self.metadata = None - - -class Metadata(_serialization.Model): - """Metadata about the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioned_by: Azure offering managing this resource on-behalf-of customer. - :vartype provisioned_by: str - """ - - _validation = { - "provisioned_by": {"readonly": True}, - } - - _attribute_map = { - "provisioned_by": {"key": "provisionedBy", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioned_by = None - - -class DataCollectionRuleAssociationMetadata(Metadata): - """Metadata about the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioned_by: Azure offering managing this resource on-behalf-of customer. - :vartype provisioned_by: str - """ - - _validation = { - "provisioned_by": {"readonly": True}, - } - - _attribute_map = { - "provisioned_by": {"key": "provisionedBy", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): - """Definition of generic ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceSystemData - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - :ivar metadata: Metadata about the resource. - :vartype metadata: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationMetadata - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionRuleAssociationProxyOnlyResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "data_collection_rule_id": {"key": "properties.dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "metadata": {"key": "properties.metadata", "type": "DataCollectionRuleAssociationMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.data_collection_endpoint_id = data_collection_endpoint_id - self.provisioning_state = None - self.metadata = None - - -class DataCollectionRuleAssociationProxyOnlyResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleAssociationProxyOnlyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRuleAssociation): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - :ivar metadata: Metadata about the resource. - :vartype metadata: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationMetadata - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleAssociationMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__( - description=description, - data_collection_rule_id=data_collection_rule_id, - data_collection_endpoint_id=data_collection_endpoint_id, - **kwargs - ) - - -class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataSourcesSpec(_serialization.Model): - """Specification of data sources that will be collected. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2022_02_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2022_02_01_preview.models.ExtensionDataSource] - :ivar log_files: The list of Log files source configurations. - :vartype log_files: list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogFilesDataSource] - :ivar iis_logs: The list of IIS logs source configurations. - :vartype iis_logs: list[~azure.mgmt.monitor.v2022_02_01_preview.models.IisLogsDataSource] - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - "log_files": {"key": "logFiles", "type": "[LogFilesDataSource]"}, - "iis_logs": {"key": "iisLogs", "type": "[IisLogsDataSource]"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - log_files: Optional[List["_models.LogFilesDataSource"]] = None, - iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2022_02_01_preview.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2022_02_01_preview.models.ExtensionDataSource] - :keyword log_files: The list of Log files source configurations. - :paramtype log_files: list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogFilesDataSource] - :keyword iis_logs: The list of IIS logs source configurations. - :paramtype iis_logs: list[~azure.mgmt.monitor.v2022_02_01_preview.models.IisLogsDataSource] - """ - super().__init__(**kwargs) - self.performance_counters = performance_counters - self.windows_event_logs = windows_event_logs - self.syslog = syslog - self.extensions = extensions - self.log_files = log_files - self.iis_logs = iis_logs - - -class DataCollectionRuleDataSources(DataSourcesSpec): - """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. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2022_02_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2022_02_01_preview.models.ExtensionDataSource] - :ivar log_files: The list of Log files source configurations. - :vartype log_files: list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogFilesDataSource] - :ivar iis_logs: The list of IIS logs source configurations. - :vartype iis_logs: list[~azure.mgmt.monitor.v2022_02_01_preview.models.IisLogsDataSource] - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - "log_files": {"key": "logFiles", "type": "[LogFilesDataSource]"}, - "iis_logs": {"key": "iisLogs", "type": "[IisLogsDataSource]"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - log_files: Optional[List["_models.LogFilesDataSource"]] = None, - iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2022_02_01_preview.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2022_02_01_preview.models.ExtensionDataSource] - :keyword log_files: The list of Log files source configurations. - :paramtype log_files: list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogFilesDataSource] - :keyword iis_logs: The list of IIS logs source configurations. - :paramtype iis_logs: list[~azure.mgmt.monitor.v2022_02_01_preview.models.IisLogsDataSource] - """ - super().__init__( - performance_counters=performance_counters, - windows_event_logs=windows_event_logs, - syslog=syslog, - extensions=extensions, - log_files=log_files, - iis_logs=iis_logs, - **kwargs - ) - - -class DestinationsSpec(_serialization.Model): - """Specification of destinations that can be used in data flows. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogAnalyticsDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogAnalyticsDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - super().__init__(**kwargs) - self.log_analytics = log_analytics - self.azure_monitor_metrics = azure_monitor_metrics - - -class DataCollectionRuleDestinations(DestinationsSpec): - """The specification of destinations. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogAnalyticsDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.LogAnalyticsDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - super().__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) - - -class DataCollectionRuleMetadata(Metadata): - """Metadata about the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioned_by: Azure offering managing this resource on-behalf-of customer. - :vartype provisioned_by: str - """ - - _validation = { - "provisioned_by": {"readonly": True}, - } - - _attribute_map = { - "provisioned_by": {"key": "provisionedBy", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class DataCollectionRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". - :vartype kind: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResourceSystemData - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :vartype data_collection_endpoint_id: str - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleMetadata - :ivar stream_declarations: Declaration of custom streams used in this rule. - :vartype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_02_01_preview.models.StreamDeclaration] - :ivar data_sources: 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. - :vartype data_sources: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "location": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "immutable_id": {"readonly": True}, - "metadata": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionRuleResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "immutable_id": {"key": "properties.immutableId", "type": "str"}, - "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, - "metadata": {"key": "properties.metadata", "type": "DataCollectionRuleMetadata"}, - "stream_declarations": {"key": "properties.streamDeclarations", "type": "{StreamDeclaration}"}, - "data_sources": {"key": "properties.dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "properties.destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "properties.dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.KnownDataCollectionRuleResourceKind"]] = None, - description: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". - :paramtype kind: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleResourceKind - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :paramtype data_collection_endpoint_id: str - :keyword stream_declarations: Declaration of custom streams used in this rule. - :paramtype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_02_01_preview.models.StreamDeclaration] - :keyword data_sources: 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. - :paramtype data_sources: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataFlow] - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.kind = kind - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.immutable_id = None - self.data_collection_endpoint_id = data_collection_endpoint_id - self.metadata = None - self.stream_declarations = stream_declarations - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleResourceProperties(DataCollectionRule): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :vartype data_collection_endpoint_id: str - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleMetadata - :ivar stream_declarations: Declaration of custom streams used in this rule. - :vartype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_02_01_preview.models.StreamDeclaration] - :ivar data_sources: 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. - :vartype data_sources: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "metadata": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleMetadata"}, - "stream_declarations": {"key": "streamDeclarations", "type": "{StreamDeclaration}"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :paramtype data_collection_endpoint_id: str - :keyword stream_declarations: Declaration of custom streams used in this rule. - :paramtype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_02_01_preview.models.StreamDeclaration] - :keyword data_sources: 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. - :paramtype data_sources: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2022_02_01_preview.models.DataFlow] - """ - super().__init__( - description=description, - data_collection_endpoint_id=data_collection_endpoint_id, - stream_declarations=stream_declarations, - data_sources=data_sources, - destinations=destinations, - data_flows=data_flows, - **kwargs - ) - - -class DataCollectionRuleResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataFlow(_serialization.Model): - """Definition of which streams are sent to which destinations. - - :ivar streams: List of streams for this data flow. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataFlowStreams] - :ivar destinations: List of destinations for this data flow. - :vartype destinations: list[str] - :ivar transform_kql: The KQL query to transform stream data. - :vartype transform_kql: str - :ivar output_stream: The output stream of the transform. Only required if the transform changes - data to a different stream. - :vartype output_stream: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "destinations": {"key": "destinations", "type": "[str]"}, - "transform_kql": {"key": "transformKql", "type": "str"}, - "output_stream": {"key": "outputStream", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, - destinations: Optional[List[str]] = None, - transform_kql: Optional[str] = None, - output_stream: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: List of streams for this data flow. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownDataFlowStreams] - :keyword destinations: List of destinations for this data flow. - :paramtype destinations: list[str] - :keyword transform_kql: The KQL query to transform stream data. - :paramtype transform_kql: str - :keyword output_stream: The output stream of the transform. Only required if the transform - changes data to a different stream. - :paramtype output_stream: str - """ - super().__init__(**kwargs) - self.streams = streams - self.destinations = destinations - self.transform_kql = transform_kql - self.output_stream = output_stream - - -class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(name=name, **kwargs) - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2022_02_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.monitor.v2022_02_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponseCommonV2(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2022_02_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2022_02_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class ExtensionDataSource(_serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with - the Azure Monitor Agent. - Collected from either Windows and Linux machines, depending on which extension is defined. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownExtensionDataSourceStreams] - :ivar extension_name: The name of the VM extension. Required. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: JSON - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "extension_name": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "extension_name": {"key": "extensionName", "type": "str"}, - "extension_settings": {"key": "extensionSettings", "type": "object"}, - "input_data_sources": {"key": "inputDataSources", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - extension_name: str, - streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, - extension_settings: Optional[JSON] = None, - input_data_sources: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownExtensionDataSourceStreams] - :keyword extension_name: The name of the VM extension. Required. - :paramtype extension_name: str - :keyword extension_settings: The extension settings. The format is specific for particular - extension. - :paramtype extension_settings: JSON - :keyword input_data_sources: The list of data sources this extension needs data from. - :paramtype input_data_sources: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.extension_name = extension_name - self.extension_settings = extension_settings - self.input_data_sources = input_data_sources - self.name = name - - -class IisLogsDataSource(_serialization.Model): - """Enables IIS logs to be collected by this data collection rule. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: IIS streams. Required. - :vartype streams: list[str] - :ivar log_directories: Absolute paths file location. - :vartype log_directories: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "streams": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "log_directories": {"key": "logDirectories", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: List[str], - log_directories: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: IIS streams. Required. - :paramtype streams: list[str] - :keyword log_directories: Absolute paths file location. - :paramtype log_directories: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.log_directories = log_directories - self.name = name - - -class LogAnalyticsDestination(_serialization.Model): - """Log Analytics destination. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. - :vartype workspace_resource_id: str - :ivar workspace_id: The Customer ID of the Log Analytics workspace. - :vartype workspace_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "workspace_id": {"readonly": True}, - } - - _attribute_map = { - "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. - :paramtype workspace_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.workspace_resource_id = workspace_resource_id - self.workspace_id = None - self.name = name - - -class LogFilesDataSource(_serialization.Model): - """Definition of which custom log files will be collected by this data collection rule. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data source. Required. - :vartype streams: list[str] - :ivar file_patterns: File Patterns where the log files are located. Required. - :vartype file_patterns: list[str] - :ivar format: The data format of the log files. Required. "text" - :vartype format: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownLogFilesDataSourceFormat - :ivar settings: The log files specific settings. - :vartype settings: ~azure.mgmt.monitor.v2022_02_01_preview.models.LogFilesDataSourceSettings - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "streams": {"required": True}, - "file_patterns": {"required": True}, - "format": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "file_patterns": {"key": "filePatterns", "type": "[str]"}, - "format": {"key": "format", "type": "str"}, - "settings": {"key": "settings", "type": "LogFilesDataSourceSettings"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: List[str], - file_patterns: List[str], - format: Union[str, "_models.KnownLogFilesDataSourceFormat"], - settings: Optional["_models.LogFilesDataSourceSettings"] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data source. Required. - :paramtype streams: list[str] - :keyword file_patterns: File Patterns where the log files are located. Required. - :paramtype file_patterns: list[str] - :keyword format: The data format of the log files. Required. "text" - :paramtype format: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownLogFilesDataSourceFormat - :keyword settings: The log files specific settings. - :paramtype settings: ~azure.mgmt.monitor.v2022_02_01_preview.models.LogFilesDataSourceSettings - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.file_patterns = file_patterns - self.format = format - self.settings = settings - self.name = name - - -class LogFileSettings(_serialization.Model): - """Settings for different log file formats. - - :ivar text: Text settings. - :vartype text: ~azure.mgmt.monitor.v2022_02_01_preview.models.LogFileSettingsText - """ - - _attribute_map = { - "text": {"key": "text", "type": "LogFileSettingsText"}, - } - - def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs: Any) -> None: - """ - :keyword text: Text settings. - :paramtype text: ~azure.mgmt.monitor.v2022_02_01_preview.models.LogFileSettingsText - """ - super().__init__(**kwargs) - self.text = text - - -class LogFilesDataSourceSettings(LogFileSettings): - """The log files specific settings. - - :ivar text: Text settings. - :vartype text: ~azure.mgmt.monitor.v2022_02_01_preview.models.LogFileSettingsText - """ - - _attribute_map = { - "text": {"key": "text", "type": "LogFileSettingsText"}, - } - - def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs: Any) -> None: - """ - :keyword text: Text settings. - :paramtype text: ~azure.mgmt.monitor.v2022_02_01_preview.models.LogFileSettingsText - """ - super().__init__(text=text, **kwargs) - - -class LogFileTextSettings(_serialization.Model): - """Settings for text log files. - - All required parameters must be populated in order to send to Azure. - - :ivar record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :vartype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - - _validation = { - "record_start_timestamp_format": {"required": True}, - } - - _attribute_map = { - "record_start_timestamp_format": {"key": "recordStartTimestampFormat", "type": "str"}, - } - - def __init__( - self, - *, - record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], - **kwargs: Any - ) -> None: - """ - :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :paramtype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - super().__init__(**kwargs) - self.record_start_timestamp_format = record_start_timestamp_format - - -class LogFileSettingsText(LogFileTextSettings): - """Text settings. - - All required parameters must be populated in order to send to Azure. - - :ivar record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :vartype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - - _validation = { - "record_start_timestamp_format": {"required": True}, - } - - _attribute_map = { - "record_start_timestamp_format": {"key": "recordStartTimestampFormat", "type": "str"}, - } - - def __init__( - self, - *, - record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], - **kwargs: Any - ) -> None: - """ - :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :paramtype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - super().__init__(record_start_timestamp_format=record_start_timestamp_format, **kwargs) - - -class PerfCounterDataSource(_serialization.Model): - """Definition of which performance counters will be collected and how they will be collected by - this data collection rule. - Collected from both Windows and Linux machines where the counter is present. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: 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'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "sampling_frequency_in_seconds": {"key": "samplingFrequencyInSeconds", "type": "int"}, - "counter_specifiers": {"key": "counterSpecifiers", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownPerfCounterDataSourceStreams"]]] = None, - sampling_frequency_in_seconds: Optional[int] = None, - counter_specifiers: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownPerfCounterDataSourceStreams] - :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :paramtype sampling_frequency_in_seconds: int - :keyword counter_specifiers: 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'. - :paramtype counter_specifiers: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.sampling_frequency_in_seconds = sampling_frequency_in_seconds - self.counter_specifiers = counter_specifiers - self.name = name - - -class ResourceForUpdate(_serialization.Model): - """Definition of ARM tracked top level resource properties for update operation. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class StreamDeclaration(_serialization.Model): - """Declaration of a custom stream. - - :ivar columns: List of columns used by data in this stream. - :vartype columns: list[~azure.mgmt.monitor.v2022_02_01_preview.models.ColumnDefinition] - """ - - _attribute_map = { - "columns": {"key": "columns", "type": "[ColumnDefinition]"}, - } - - def __init__(self, *, columns: Optional[List["_models.ColumnDefinition"]] = None, **kwargs: Any) -> None: - """ - :keyword columns: List of columns used by data in this stream. - :paramtype columns: list[~azure.mgmt.monitor.v2022_02_01_preview.models.ColumnDefinition] - """ - super().__init__(**kwargs) - self.columns = columns - - -class SyslogDataSource(_serialization.Model): - """Definition of which syslog data will be collected and how it will be collected. - Only collected from Linux machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "facility_names": {"key": "facilityNames", "type": "[str]"}, - "log_levels": {"key": "logLevels", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownSyslogDataSourceStreams"]]] = None, - facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, - log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownSyslogDataSourceStreams] - :keyword facility_names: The list of facility names. - :paramtype facility_names: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownSyslogDataSourceFacilityNames] - :keyword log_levels: The log levels to collect. - :paramtype log_levels: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownSyslogDataSourceLogLevels] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.facility_names = facility_names - self.log_levels = log_levels - self.name = name - - -class WindowsEventLogDataSource(_serialization.Model): - """Definition of which Windows Event Log events will be collected and how they will be collected. - Only collected from Windows machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "x_path_queries": {"key": "xPathQueries", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, - x_path_queries: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_02_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. - :paramtype x_path_queries: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.x_path_queries = x_path_queries - self.name = name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 0ae017838570d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class KnownColumnDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the column data.""" - - STRING = "string" - INT = "int" - LONG = "long" - REAL = "real" - BOOLEAN = "boolean" - DATETIME = "datetime" - DYNAMIC = "dynamic" - - -class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. This property is READ-ONLY.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionEndpointResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource.""" - - LINUX = "Linux" - WINDOWS = "Windows" - - -class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - - -class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource.""" - - LINUX = "Linux" - WINDOWS = "Windows" - - -class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownDataFlowStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownExtensionDataSourceStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownLogFilesDataSourceFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The data format of the log files.""" - - TEXT = "text" - - -class KnownLogFileTextSettingsRecordStartTimestampFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """One of the supported timestamp formats.""" - - ISO8601 = "ISO 8601" - YYYY_MM_DD_HH_MM_SS = "YYYY-MM-DD HH:MM:SS" - M_D_YYYY_HH_MM_SS_AM_PM = "M/D/YYYY HH:MM:SS AM/PM" - MON_DD_YYYY_HH_MM_SS = "Mon DD, YYYY HH:MM:SS" - YY_M_MDD_HH_MM_SS = "yyMMdd HH:mm:ss" - DD_M_MYY_HH_MM_SS = "ddMMyy HH:mm:ss" - MMM_D_HH_MM_SS = "MMM d hh:mm:ss" - DD_MMM_YYYY_HH_MM_SS_ZZZ = "dd/MMM/yyyy:HH:mm:ss zzz" - YYYY_MM_DD_THH_MM_SS_K = "yyyy-MM-ddTHH:mm:ssK" - - -class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownPerfCounterDataSourceStreams.""" - - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - - -class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The configuration to set whether network access from public internet to the endpoints are - allowed. - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - - -class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceFacilityNames.""" - - AUTH = "auth" - AUTHPRIV = "authpriv" - CRON = "cron" - DAEMON = "daemon" - KERN = "kern" - LPR = "lpr" - MAIL = "mail" - MARK = "mark" - NEWS = "news" - SYSLOG = "syslog" - USER = "user" - UUCP = "uucp" - LOCAL0 = "local0" - LOCAL1 = "local1" - LOCAL2 = "local2" - LOCAL3 = "local3" - LOCAL4 = "local4" - LOCAL5 = "local5" - LOCAL6 = "local6" - LOCAL7 = "local7" - ASTERISK = "*" - - -class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceLogLevels.""" - - DEBUG = "Debug" - INFO = "Info" - NOTICE = "Notice" - WARNING = "Warning" - ERROR = "Error" - CRITICAL = "Critical" - ALERT = "Alert" - EMERGENCY = "Emergency" - ASTERISK = "*" - - -class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceStreams.""" - - MICROSOFT_SYSLOG = "Microsoft-Syslog" - - -class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownWindowsEventLogDataSourceStreams.""" - - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py deleted file mode 100644 index 842046dd09e5f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._data_collection_endpoints_operations import DataCollectionEndpointsOperations -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DataCollectionEndpointsOperations", - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py deleted file mode 100644 index 05f8e5f022431..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py +++ /dev/null @@ -1,884 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_02_01_preview.MonitorManagementClient`'s - :attr:`data_collection_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified resource group. - - Lists all data collection endpoints in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified subscription. - - Lists all data collection endpoints in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Returns the specified data collection endpoint. - - Returns the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.DataCollectionEndpointResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionEndpointResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection endpoint. - - Deletes a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index f25e0ce5a1f9a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,806 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_rule_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_data_collection_endpoint_request( # pylint: disable=name-too-long - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_02_01_preview.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace - def list_by_data_collection_endpoint( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection endpoint. - - Lists associations for the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_data_collection_endpoint_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_data_collection_endpoint.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_data_collection_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations" - } - - @distributed_trace - def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: - ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py deleted file mode 100644 index cac42d3bef4c5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,876 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_02_01_preview.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_02_01_preview.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_02_01_preview.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py deleted file mode 100644 index 660245741936e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json deleted file mode 100644 index c8694bb8c160a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-04-01", - "total_api_version_list": ["2022-04-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py deleted file mode 100644 index a0198919ab769..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2022_04_01.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py deleted file mode 100644 index 3df538e5f118e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py deleted file mode 100644 index 4c55b4206c0b2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2022_04_01.aio.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index f75b03332f7a7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,1343 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_notifications_at_resource_group_level_request, - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_get_test_notifications_at_resource_group_level_request, - build_get_test_notifications_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_post_test_notifications_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_04_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - async def _post_test_notifications_initial( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_post_test_notifications_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._post_test_notifications_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_test_notifications_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - @overload - async def begin_post_test_notifications( - self, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_post_test_notifications( - self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_post_test_notifications( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._post_test_notifications_initial( - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_post_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - async def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_resource_group_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @overload - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_notifications_at_resource_group_level_initial( - resource_group_name=resource_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @distributed_trace_async - async def get_test_notifications( - self, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_request( - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace_async - async def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2022_04_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2022_04_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py deleted file mode 100644 index b1dac637c4030..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionDetail -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ArmRoleReceiver -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import AzureResource -from ._models_py3 import Context -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import EventHubReceiver -from ._models_py3 import ItsmReceiver -from ._models_py3 import LogicAppReceiver -from ._models_py3 import NotificationRequestBody -from ._models_py3 import SmsReceiver -from ._models_py3 import TestNotificationDetailsResponse -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionDetail", - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ArmRoleReceiver", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "AzureResource", - "Context", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "EventHubReceiver", - "ItsmReceiver", - "LogicAppReceiver", - "NotificationRequestBody", - "SmsReceiver", - "TestNotificationDetailsResponse", - "VoiceReceiver", - "WebhookReceiver", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py deleted file mode 100644 index b71023d76c8fe..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py +++ /dev/null @@ -1,1240 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionDetail(_serialization.Model): - """The action detail. - - :ivar mechanism_type: The mechanism type. - :vartype mechanism_type: str - :ivar name: The name of the action. - :vartype name: str - :ivar status: The status of the action. - :vartype status: str - :ivar sub_state: The substatus of the action. - :vartype sub_state: str - :ivar send_time: The send time. - :vartype send_time: str - :ivar detail: The detail of the friendly error message. - :vartype detail: str - """ - - _attribute_map = { - "mechanism_type": {"key": "MechanismType", "type": "str"}, - "name": {"key": "Name", "type": "str"}, - "status": {"key": "Status", "type": "str"}, - "sub_state": {"key": "SubState", "type": "str"}, - "send_time": {"key": "SendTime", "type": "str"}, - "detail": {"key": "Detail", "type": "str"}, - } - - def __init__( - self, - *, - mechanism_type: Optional[str] = None, - name: Optional[str] = None, - status: Optional[str] = None, - sub_state: Optional[str] = None, - send_time: Optional[str] = None, - detail: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword mechanism_type: The mechanism type. - :paramtype mechanism_type: str - :keyword name: The name of the action. - :paramtype name: str - :keyword status: The status of the action. - :paramtype status: str - :keyword sub_state: The substatus of the action. - :paramtype sub_state: str - :keyword send_time: The send time. - :paramtype send_time: str - :keyword detail: The detail of the friendly error message. - :paramtype detail: str - """ - super().__init__(**kwargs) - self.mechanism_type = mechanism_type - self.name = name - self.status = status - self.sub_state = sub_state - self.send_time = send_time - self.detail = detail - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class AzureResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EventHubReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EventHubReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class ArmRoleReceiver(_serialization.Model): - """An arm role receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the arm role receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar role_id: The arm role id. Required. - :vartype role_id: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "role_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "role_id": {"key": "roleId", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the arm role receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword role_id: The arm role id. Required. - :paramtype role_id: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.role_id = role_id - self.use_common_alert_schema = use_common_alert_schema - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - self.use_common_alert_schema = use_common_alert_schema - - -class Context(_serialization.Model): - """The context info. - - :ivar notification_source: The source of the notification request. - :vartype notification_source: str - :ivar context_type: The context id type. - :vartype context_type: str - """ - - _attribute_map = { - "notification_source": {"key": "notificationSource", "type": "str"}, - "context_type": {"key": "contextType", "type": "str"}, - } - - def __init__( - self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword notification_source: The source of the notification request. - :paramtype notification_source: str - :keyword context_type: The context id type. - :paramtype context_type: str - """ - super().__init__(**kwargs) - self.notification_source = notification_source - self.context_type = context_type - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2022_04_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.use_common_alert_schema = use_common_alert_schema - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class EventHubReceiver(_serialization.Model): - """An Event hub receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar event_hub_name_space: The Event Hub namespace. Required. - :vartype event_hub_name_space: str - :ivar event_hub_name: The name of the specific Event Hub queue. Required. - :vartype event_hub_name: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar tenant_id: The tenant Id for the subscription containing this event hub. - :vartype tenant_id: str - :ivar subscription_id: The Id for the subscription containing this event hub. Required. - :vartype subscription_id: str - """ - - _validation = { - "name": {"required": True}, - "event_hub_name_space": {"required": True}, - "event_hub_name": {"required": True}, - "subscription_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, - "event_hub_name": {"key": "eventHubName", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - event_hub_name_space: str, - event_hub_name: str, - subscription_id: str, - use_common_alert_schema: bool = False, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword event_hub_name_space: The Event Hub namespace. Required. - :paramtype event_hub_name_space: str - :keyword event_hub_name: The name of the specific Event Hub queue. Required. - :paramtype event_hub_name: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword tenant_id: The tenant Id for the subscription containing this event hub. - :paramtype tenant_id: str - :keyword subscription_id: The Id for the subscription containing this event hub. Required. - :paramtype subscription_id: str - """ - super().__init__(**kwargs) - self.name = name - self.event_hub_name_space = event_hub_name_space - self.event_hub_name = event_hub_name - self.use_common_alert_schema = use_common_alert_schema - self.tenant_id = tenant_id - self.subscription_id = subscription_id - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - self.use_common_alert_schema = use_common_alert_schema - - -class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The request body which contain contact detail metadata. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :vartype alert_type: str - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EventHubReceiver] - """ - - _validation = { - "alert_type": {"required": True, "max_length": 30}, - } - - _attribute_map = { - "alert_type": {"key": "alertType", "type": "str"}, - "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, - "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - alert_type: str, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :paramtype alert_type: str - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_04_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2022_04_01.models.EventHubReceiver] - """ - super().__init__(**kwargs) - self.alert_type = alert_type - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2022_04_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class TestNotificationDetailsResponse(_serialization.Model): - """The details of the test notification results. - - All required parameters must be populated in order to send to Azure. - - :ivar context: The context info. - :vartype context: ~azure.mgmt.monitor.v2022_04_01.models.Context - :ivar state: The overall state. Required. - :vartype state: str - :ivar completed_time: The completed time. - :vartype completed_time: str - :ivar created_time: The created time. - :vartype created_time: str - :ivar action_details: The list of action detail. - :vartype action_details: list[~azure.mgmt.monitor.v2022_04_01.models.ActionDetail] - """ - - _validation = { - "state": {"required": True}, - } - - _attribute_map = { - "context": {"key": "context", "type": "Context"}, - "state": {"key": "state", "type": "str"}, - "completed_time": {"key": "completedTime", "type": "str"}, - "created_time": {"key": "createdTime", "type": "str"}, - "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, - } - - def __init__( - self, - *, - state: str, - context: Optional["_models.Context"] = None, - completed_time: Optional[str] = None, - created_time: Optional[str] = None, - action_details: Optional[List["_models.ActionDetail"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context: The context info. - :paramtype context: ~azure.mgmt.monitor.v2022_04_01.models.Context - :keyword state: The overall state. Required. - :paramtype state: str - :keyword completed_time: The completed time. - :paramtype completed_time: str - :keyword created_time: The created time. - :paramtype created_time: str - :keyword action_details: The list of action detail. - :paramtype action_details: list[~azure.mgmt.monitor.v2022_04_01.models.ActionDetail] - """ - super().__init__(**kwargs) - self.context = context - self.state = state - self.completed_time = completed_time - self.created_time = created_time - self.action_details = action_details - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar use_aad_auth: Indicates whether or not use AAD authentication. - :vartype use_aad_auth: bool - :ivar object_id: Indicates the webhook app object Id for aad auth. - :vartype object_id: str - :ivar identifier_uri: Indicates the identifier uri for aad auth. - :vartype identifier_uri: str - :ivar tenant_id: Indicates the tenant id for aad auth. - :vartype tenant_id: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, - "object_id": {"key": "objectId", "type": "str"}, - "identifier_uri": {"key": "identifierUri", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - service_uri: str, - use_common_alert_schema: bool = False, - use_aad_auth: bool = False, - object_id: Optional[str] = None, - identifier_uri: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword use_aad_auth: Indicates whether or not use AAD authentication. - :paramtype use_aad_auth: bool - :keyword object_id: Indicates the webhook app object Id for aad auth. - :paramtype object_id: str - :keyword identifier_uri: Indicates the identifier uri for aad auth. - :paramtype identifier_uri: str - :keyword tenant_id: Indicates the tenant id for aad auth. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - self.use_aad_auth = use_aad_auth - self.object_id = object_id - self.identifier_uri = identifier_uri - self.tenant_id = tenant_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 2502d854d1869..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py deleted file mode 100644 index fe3985a8494a5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,1684 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_notifications_at_resource_group_level_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_request(notification_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_at_resource_group_level_request( # pylint: disable=name-too-long - resource_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_04_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - def _post_test_notifications_initial( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_post_test_notifications_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._post_test_notifications_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_test_notifications_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - @overload - def begin_post_test_notifications( - self, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_post_test_notifications( - self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_post_test_notifications( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._post_test_notifications_initial( - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_post_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_resource_group_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @overload - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_04_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_notifications_at_resource_group_level_initial( - resource_group_name=resource_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @distributed_trace - def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_request( - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace - def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_04_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_04_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2022_04_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2022_04_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py deleted file mode 100644 index 3f9c93c26b65a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json deleted file mode 100644 index 8b2e5676ece47..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2022-06-01", - "total_api_version_list": ["2022-06-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations", - "data_collection_endpoints": "DataCollectionEndpointsOperations", - "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", - "data_collection_rules": "DataCollectionRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py deleted file mode 100644 index bace8c7fbbe61..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - ActionGroupsOperations, - DataCollectionEndpointsOperations, - DataCollectionRuleAssociationsOperations, - DataCollectionRulesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2022_06_01.operations.ActionGroupsOperations - :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: - azure.mgmt.monitor.v2022_06_01.operations.DataCollectionEndpointsOperations - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2022_06_01.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2022_06_01.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py deleted file mode 100644 index 233b355cd156a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py deleted file mode 100644 index 628c870841c8f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ( - ActionGroupsOperations, - DataCollectionEndpointsOperations, - DataCollectionRuleAssociationsOperations, - DataCollectionRulesOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2022_06_01.aio.operations.ActionGroupsOperations - :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: - azure.mgmt.monitor.v2022_06_01.aio.operations.DataCollectionEndpointsOperations - :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: - azure.mgmt.monitor.v2022_06_01.aio.operations.DataCollectionRuleAssociationsOperations - :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: - azure.mgmt.monitor.v2022_06_01.aio.operations.DataCollectionRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py deleted file mode 100644 index 134b182d222e9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._data_collection_endpoints_operations import DataCollectionEndpointsOperations -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "DataCollectionEndpointsOperations", - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index 6dddebf368bdb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,1649 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_notifications_at_action_group_resource_level_request, - build_create_notifications_at_resource_group_level_request, - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_get_test_notifications_at_action_group_resource_level_request, - build_get_test_notifications_at_resource_group_level_request, - build_get_test_notifications_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_post_test_notifications_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - async def _post_test_notifications_initial( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_post_test_notifications_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._post_test_notifications_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_test_notifications_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - @overload - async def begin_post_test_notifications( - self, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_post_test_notifications( - self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_post_test_notifications( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._post_test_notifications_initial( - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_post_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - async def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_resource_group_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @overload - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_notifications_at_resource_group_level_initial( - resource_group_name=resource_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - async def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_action_group_resource_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @overload - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_notifications_at_action_group_resource_level_initial( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @distributed_trace_async - async def get_test_notifications( - self, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_request( - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace_async - async def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace_async - async def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2022_06_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2022_06_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_endpoints_operations.py deleted file mode 100644 index c35260518aa90..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_endpoints_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_endpoints_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.aio.MonitorManagementClient`'s - :attr:`data_collection_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified resource group. - - Lists all data collection endpoints in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified subscription. - - Lists all data collection endpoints in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Returns the specified data collection endpoint. - - Returns the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.DataCollectionEndpointResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionEndpointResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection endpoint. - - Deletes a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index 985bffa7cbb0a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,630 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rule_associations_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_data_collection_endpoint_request, - build_list_by_resource_request, - build_list_by_rule_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.aio.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace - def list_by_data_collection_endpoint( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection endpoint. - - Lists associations for the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_data_collection_endpoint_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_data_collection_endpoint.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_data_collection_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations" - } - - @distributed_trace_async - async def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_rules_operations.py deleted file mode 100644 index 3e861dea15bc4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._data_collection_rules_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.aio.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py deleted file mode 100644 index 10260a1c0f482..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py +++ /dev/null @@ -1,247 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionDetail -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ArmRoleReceiver -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import AzureMonitorMetricsDestination -from ._models_py3 import AzureResource -from ._models_py3 import ColumnDefinition -from ._models_py3 import ConfigurationAccessEndpointSpec -from ._models_py3 import Context -from ._models_py3 import DataCollectionEndpoint -from ._models_py3 import DataCollectionEndpointConfigurationAccess -from ._models_py3 import DataCollectionEndpointFailoverConfiguration -from ._models_py3 import DataCollectionEndpointLogsIngestion -from ._models_py3 import DataCollectionEndpointMetadata -from ._models_py3 import DataCollectionEndpointMetricsIngestion -from ._models_py3 import DataCollectionEndpointNetworkAcls -from ._models_py3 import DataCollectionEndpointResource -from ._models_py3 import DataCollectionEndpointResourceIdentity -from ._models_py3 import DataCollectionEndpointResourceListResult -from ._models_py3 import DataCollectionEndpointResourceProperties -from ._models_py3 import DataCollectionEndpointResourceSystemData -from ._models_py3 import DataCollectionRule -from ._models_py3 import DataCollectionRuleAssociation -from ._models_py3 import DataCollectionRuleAssociationMetadata -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties -from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceSystemData -from ._models_py3 import DataCollectionRuleDataSources -from ._models_py3 import DataCollectionRuleDestinations -from ._models_py3 import DataCollectionRuleMetadata -from ._models_py3 import DataCollectionRuleResource -from ._models_py3 import DataCollectionRuleResourceIdentity -from ._models_py3 import DataCollectionRuleResourceListResult -from ._models_py3 import DataCollectionRuleResourceProperties -from ._models_py3 import DataCollectionRuleResourceSystemData -from ._models_py3 import DataFlow -from ._models_py3 import DataImportSources -from ._models_py3 import DataImportSourcesEventHub -from ._models_py3 import DataSourcesSpec -from ._models_py3 import DataSourcesSpecDataImports -from ._models_py3 import DestinationsSpec -from ._models_py3 import DestinationsSpecAzureMonitorMetrics -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import ErrorResponseCommonV2 -from ._models_py3 import EventHubDataSource -from ._models_py3 import EventHubDestination -from ._models_py3 import EventHubDirectDestination -from ._models_py3 import EventHubReceiver -from ._models_py3 import ExtensionDataSource -from ._models_py3 import FailoverConfigurationSpec -from ._models_py3 import IisLogsDataSource -from ._models_py3 import ItsmReceiver -from ._models_py3 import LocationSpec -from ._models_py3 import LogAnalyticsDestination -from ._models_py3 import LogFileSettings -from ._models_py3 import LogFileSettingsText -from ._models_py3 import LogFileTextSettings -from ._models_py3 import LogFilesDataSource -from ._models_py3 import LogFilesDataSourceSettings -from ._models_py3 import LogicAppReceiver -from ._models_py3 import LogsIngestionEndpointSpec -from ._models_py3 import ManagedServiceIdentity -from ._models_py3 import Metadata -from ._models_py3 import MetricsIngestionEndpointSpec -from ._models_py3 import MonitoringAccountDestination -from ._models_py3 import NetworkRuleSet -from ._models_py3 import NotificationRequestBody -from ._models_py3 import PerfCounterDataSource -from ._models_py3 import PlatformTelemetryDataSource -from ._models_py3 import PrivateLinkScopedResource -from ._models_py3 import PrometheusForwarderDataSource -from ._models_py3 import ResourceForUpdate -from ._models_py3 import ResourceForUpdateIdentity -from ._models_py3 import SmsReceiver -from ._models_py3 import StorageBlobDestination -from ._models_py3 import StorageTableDestination -from ._models_py3 import StreamDeclaration -from ._models_py3 import SyslogDataSource -from ._models_py3 import SystemData -from ._models_py3 import TestNotificationDetailsResponse -from ._models_py3 import UserAssignedIdentity -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver -from ._models_py3 import WindowsEventLogDataSource -from ._models_py3 import WindowsFirewallLogsDataSource - -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import KnownColumnDefinitionType -from ._monitor_management_client_enums import KnownDataCollectionEndpointProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionEndpointResourceKind -from ._monitor_management_client_enums import KnownDataCollectionRuleAssociationProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleProvisioningState -from ._monitor_management_client_enums import KnownDataCollectionRuleResourceKind -from ._monitor_management_client_enums import KnownDataFlowStreams -from ._monitor_management_client_enums import KnownExtensionDataSourceStreams -from ._monitor_management_client_enums import KnownLocationSpecProvisioningStatus -from ._monitor_management_client_enums import KnownLogFileTextSettingsRecordStartTimestampFormat -from ._monitor_management_client_enums import KnownLogFilesDataSourceFormat -from ._monitor_management_client_enums import KnownPerfCounterDataSourceStreams -from ._monitor_management_client_enums import KnownPrometheusForwarderDataSourceStreams -from ._monitor_management_client_enums import KnownPublicNetworkAccessOptions -from ._monitor_management_client_enums import KnownSyslogDataSourceFacilityNames -from ._monitor_management_client_enums import KnownSyslogDataSourceLogLevels -from ._monitor_management_client_enums import KnownSyslogDataSourceStreams -from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams -from ._monitor_management_client_enums import ManagedServiceIdentityType -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionDetail", - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ArmRoleReceiver", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "AzureMonitorMetricsDestination", - "AzureResource", - "ColumnDefinition", - "ConfigurationAccessEndpointSpec", - "Context", - "DataCollectionEndpoint", - "DataCollectionEndpointConfigurationAccess", - "DataCollectionEndpointFailoverConfiguration", - "DataCollectionEndpointLogsIngestion", - "DataCollectionEndpointMetadata", - "DataCollectionEndpointMetricsIngestion", - "DataCollectionEndpointNetworkAcls", - "DataCollectionEndpointResource", - "DataCollectionEndpointResourceIdentity", - "DataCollectionEndpointResourceListResult", - "DataCollectionEndpointResourceProperties", - "DataCollectionEndpointResourceSystemData", - "DataCollectionRule", - "DataCollectionRuleAssociation", - "DataCollectionRuleAssociationMetadata", - "DataCollectionRuleAssociationProxyOnlyResource", - "DataCollectionRuleAssociationProxyOnlyResourceListResult", - "DataCollectionRuleAssociationProxyOnlyResourceProperties", - "DataCollectionRuleAssociationProxyOnlyResourceSystemData", - "DataCollectionRuleDataSources", - "DataCollectionRuleDestinations", - "DataCollectionRuleMetadata", - "DataCollectionRuleResource", - "DataCollectionRuleResourceIdentity", - "DataCollectionRuleResourceListResult", - "DataCollectionRuleResourceProperties", - "DataCollectionRuleResourceSystemData", - "DataFlow", - "DataImportSources", - "DataImportSourcesEventHub", - "DataSourcesSpec", - "DataSourcesSpecDataImports", - "DestinationsSpec", - "DestinationsSpecAzureMonitorMetrics", - "EmailReceiver", - "EnableRequest", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "ErrorResponseCommonV2", - "EventHubDataSource", - "EventHubDestination", - "EventHubDirectDestination", - "EventHubReceiver", - "ExtensionDataSource", - "FailoverConfigurationSpec", - "IisLogsDataSource", - "ItsmReceiver", - "LocationSpec", - "LogAnalyticsDestination", - "LogFileSettings", - "LogFileSettingsText", - "LogFileTextSettings", - "LogFilesDataSource", - "LogFilesDataSourceSettings", - "LogicAppReceiver", - "LogsIngestionEndpointSpec", - "ManagedServiceIdentity", - "Metadata", - "MetricsIngestionEndpointSpec", - "MonitoringAccountDestination", - "NetworkRuleSet", - "NotificationRequestBody", - "PerfCounterDataSource", - "PlatformTelemetryDataSource", - "PrivateLinkScopedResource", - "PrometheusForwarderDataSource", - "ResourceForUpdate", - "ResourceForUpdateIdentity", - "SmsReceiver", - "StorageBlobDestination", - "StorageTableDestination", - "StreamDeclaration", - "SyslogDataSource", - "SystemData", - "TestNotificationDetailsResponse", - "UserAssignedIdentity", - "VoiceReceiver", - "WebhookReceiver", - "WindowsEventLogDataSource", - "WindowsFirewallLogsDataSource", - "CreatedByType", - "KnownColumnDefinitionType", - "KnownDataCollectionEndpointProvisioningState", - "KnownDataCollectionEndpointResourceKind", - "KnownDataCollectionRuleAssociationProvisioningState", - "KnownDataCollectionRuleProvisioningState", - "KnownDataCollectionRuleResourceKind", - "KnownDataFlowStreams", - "KnownExtensionDataSourceStreams", - "KnownLocationSpecProvisioningStatus", - "KnownLogFileTextSettingsRecordStartTimestampFormat", - "KnownLogFilesDataSourceFormat", - "KnownPerfCounterDataSourceStreams", - "KnownPrometheusForwarderDataSourceStreams", - "KnownPublicNetworkAccessOptions", - "KnownSyslogDataSourceFacilityNames", - "KnownSyslogDataSourceLogLevels", - "KnownSyslogDataSourceStreams", - "KnownWindowsEventLogDataSourceStreams", - "ManagedServiceIdentityType", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py deleted file mode 100644 index 2b564b89bfb06..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py +++ /dev/null @@ -1,4847 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class ActionDetail(_serialization.Model): - """The action detail. - - :ivar mechanism_type: The mechanism type. - :vartype mechanism_type: str - :ivar name: The name of the action. - :vartype name: str - :ivar status: The status of the action. - :vartype status: str - :ivar sub_state: The substatus of the action. - :vartype sub_state: str - :ivar send_time: The send time. - :vartype send_time: str - :ivar detail: The detail of the friendly error message. - :vartype detail: str - """ - - _attribute_map = { - "mechanism_type": {"key": "MechanismType", "type": "str"}, - "name": {"key": "Name", "type": "str"}, - "status": {"key": "Status", "type": "str"}, - "sub_state": {"key": "SubState", "type": "str"}, - "send_time": {"key": "SendTime", "type": "str"}, - "detail": {"key": "Detail", "type": "str"}, - } - - def __init__( - self, - *, - mechanism_type: Optional[str] = None, - name: Optional[str] = None, - status: Optional[str] = None, - sub_state: Optional[str] = None, - send_time: Optional[str] = None, - detail: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword mechanism_type: The mechanism type. - :paramtype mechanism_type: str - :keyword name: The name of the action. - :paramtype name: str - :keyword status: The status of the action. - :paramtype status: str - :keyword sub_state: The substatus of the action. - :paramtype sub_state: str - :keyword send_time: The send time. - :paramtype send_time: str - :keyword detail: The detail of the friendly error message. - :paramtype detail: str - """ - super().__init__(**kwargs) - self.mechanism_type = mechanism_type - self.name = name - self.status = status - self.sub_state = sub_state - self.send_time = send_time - self.detail = detail - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class AzureResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class ArmRoleReceiver(_serialization.Model): - """An arm role receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the arm role receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar role_id: The arm role id. Required. - :vartype role_id: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "role_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "role_id": {"key": "roleId", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the arm role receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword role_id: The arm role id. Required. - :paramtype role_id: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.role_id = role_id - self.use_common_alert_schema = use_common_alert_schema - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - self.use_common_alert_schema = use_common_alert_schema - - -class AzureMonitorMetricsDestination(_serialization.Model): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class ColumnDefinition(_serialization.Model): - """Definition of custom data column. - - :ivar name: The name of the column. - :vartype name: str - :ivar type: The type of the column data. Known values are: "string", "int", "long", "real", - "boolean", "datetime", and "dynamic". - :vartype type: str or ~azure.mgmt.monitor.v2022_06_01.models.KnownColumnDefinitionType - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.KnownColumnDefinitionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the column. - :paramtype name: str - :keyword type: The type of the column data. Known values are: "string", "int", "long", "real", - "boolean", "datetime", and "dynamic". - :paramtype type: str or ~azure.mgmt.monitor.v2022_06_01.models.KnownColumnDefinitionType - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class ConfigurationAccessEndpointSpec(_serialization.Model): - """Definition of the endpoint used for accessing configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.endpoint = None - - -class Context(_serialization.Model): - """The context info. - - :ivar notification_source: The source of the notification request. - :vartype notification_source: str - :ivar context_type: The context id type. - :vartype context_type: str - """ - - _attribute_map = { - "notification_source": {"key": "notificationSource", "type": "str"}, - "context_type": {"key": "contextType", "type": "str"}, - } - - def __init__( - self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword notification_source: The source of the notification request. - :paramtype notification_source: str - :keyword context_type: The context id type. - :paramtype context_type: str - """ - super().__init__(**kwargs) - self.notification_source = notification_source - self.context_type = context_type - - -class DataCollectionEndpoint(_serialization.Model): - """Definition of data collection endpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by clients to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointLogsIngestion - :ivar metrics_ingestion: The endpoint used by clients to ingest metrics. - :vartype metrics_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetricsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionEndpointProvisioningState - :ivar private_link_scoped_resources: List of Azure Monitor Private Link Scope Resources to - which this data collection endpoint resource is associated. This property is READ-ONLY. - :vartype private_link_scoped_resources: - list[~azure.mgmt.monitor.v2022_06_01.models.PrivateLinkScopedResource] - :ivar failover_configuration: Failover configuration on this endpoint. This property is - READ-ONLY. - :vartype failover_configuration: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointFailoverConfiguration - :ivar metadata: Metadata for the resource. This property is READ-ONLY. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetadata - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "private_link_scoped_resources": {"readonly": True}, - "failover_configuration": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, - "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "metrics_ingestion": {"key": "metricsIngestion", "type": "DataCollectionEndpointMetricsIngestion"}, - "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_link_scoped_resources": {"key": "privateLinkScopedResources", "type": "[PrivateLinkScopedResource]"}, - "failover_configuration": { - "key": "failoverConfiguration", - "type": "DataCollectionEndpointFailoverConfiguration", - }, - "metadata": {"key": "metadata", "type": "DataCollectionEndpointMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - metrics_ingestion: Optional["_models.DataCollectionEndpointMetricsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by clients to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointLogsIngestion - :keyword metrics_ingestion: The endpoint used by clients to ingest metrics. - :paramtype metrics_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetricsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointNetworkAcls - """ - super().__init__(**kwargs) - self.description = description - self.immutable_id = immutable_id - self.configuration_access = configuration_access - self.logs_ingestion = logs_ingestion - self.metrics_ingestion = metrics_ingestion - self.network_acls = network_acls - self.provisioning_state = None - self.private_link_scoped_resources = None - self.failover_configuration = None - self.metadata = None - - -class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec): - """The endpoint used by clients to access their configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class FailoverConfigurationSpec(_serialization.Model): - """FailoverConfigurationSpec. - - :ivar active_location: Active location where data flow will occur. - :vartype active_location: str - :ivar locations: Locations that are configured for failover. - :vartype locations: list[~azure.mgmt.monitor.v2022_06_01.models.LocationSpec] - """ - - _attribute_map = { - "active_location": {"key": "activeLocation", "type": "str"}, - "locations": {"key": "locations", "type": "[LocationSpec]"}, - } - - def __init__( - self, - *, - active_location: Optional[str] = None, - locations: Optional[List["_models.LocationSpec"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword active_location: Active location where data flow will occur. - :paramtype active_location: str - :keyword locations: Locations that are configured for failover. - :paramtype locations: list[~azure.mgmt.monitor.v2022_06_01.models.LocationSpec] - """ - super().__init__(**kwargs) - self.active_location = active_location - self.locations = locations - - -class DataCollectionEndpointFailoverConfiguration(FailoverConfigurationSpec): - """Failover configuration on this endpoint. This property is READ-ONLY. - - :ivar active_location: Active location where data flow will occur. - :vartype active_location: str - :ivar locations: Locations that are configured for failover. - :vartype locations: list[~azure.mgmt.monitor.v2022_06_01.models.LocationSpec] - """ - - _attribute_map = { - "active_location": {"key": "activeLocation", "type": "str"}, - "locations": {"key": "locations", "type": "[LocationSpec]"}, - } - - def __init__( - self, - *, - active_location: Optional[str] = None, - locations: Optional[List["_models.LocationSpec"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword active_location: Active location where data flow will occur. - :paramtype active_location: str - :keyword locations: Locations that are configured for failover. - :paramtype locations: list[~azure.mgmt.monitor.v2022_06_01.models.LocationSpec] - """ - super().__init__(active_location=active_location, locations=locations, **kwargs) - - -class LogsIngestionEndpointSpec(_serialization.Model): - """Definition of the endpoint used for ingesting logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): - """The endpoint used by clients to ingest logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class Metadata(_serialization.Model): - """Metadata about the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioned_by: Azure offering managing this resource on-behalf-of customer. - :vartype provisioned_by: str - :ivar provisioned_by_resource_id: Resource Id of azure offering managing this resource - on-behalf-of customer. - :vartype provisioned_by_resource_id: str - """ - - _validation = { - "provisioned_by": {"readonly": True}, - "provisioned_by_resource_id": {"readonly": True}, - } - - _attribute_map = { - "provisioned_by": {"key": "provisionedBy", "type": "str"}, - "provisioned_by_resource_id": {"key": "provisionedByResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioned_by = None - self.provisioned_by_resource_id = None - - -class DataCollectionEndpointMetadata(Metadata): - """Metadata for the resource. This property is READ-ONLY. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioned_by: Azure offering managing this resource on-behalf-of customer. - :vartype provisioned_by: str - :ivar provisioned_by_resource_id: Resource Id of azure offering managing this resource - on-behalf-of customer. - :vartype provisioned_by_resource_id: str - """ - - _validation = { - "provisioned_by": {"readonly": True}, - "provisioned_by_resource_id": {"readonly": True}, - } - - _attribute_map = { - "provisioned_by": {"key": "provisionedBy", "type": "str"}, - "provisioned_by_resource_id": {"key": "provisionedByResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class MetricsIngestionEndpointSpec(_serialization.Model): - """Definition of the endpoint used for ingesting metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpointMetricsIngestion(MetricsIngestionEndpointSpec): - """The endpoint used by clients to ingest metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - "endpoint": {"readonly": True}, - } - - _attribute_map = { - "endpoint": {"key": "endpoint", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class NetworkRuleSet(_serialization.Model): - """Definition of the network rules. - - :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled", and - "SecuredByPerimeter". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled", and - "SecuredByPerimeter". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPublicNetworkAccessOptions - """ - super().__init__(**kwargs) - self.public_network_access = public_network_access - - -class DataCollectionEndpointNetworkAcls(NetworkRuleSet): - """Network access control rules for the endpoints. - - :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled", and - "SecuredByPerimeter". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, - } - - def __init__( - self, - *, - public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Known values are: "Enabled", "Disabled", and - "SecuredByPerimeter". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPublicNetworkAccessOptions - """ - super().__init__(public_network_access=public_network_access, **kwargs) - - -class DataCollectionEndpointResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". - :vartype kind: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionEndpointResourceKind - :ivar identity: Managed service identity of the resource. - :vartype identity: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResourceIdentity - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResourceSystemData - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by clients to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointLogsIngestion - :ivar metrics_ingestion: The endpoint used by clients to ingest metrics. - :vartype metrics_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetricsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionEndpointProvisioningState - :ivar private_link_scoped_resources: List of Azure Monitor Private Link Scope Resources to - which this data collection endpoint resource is associated. This property is READ-ONLY. - :vartype private_link_scoped_resources: - list[~azure.mgmt.monitor.v2022_06_01.models.PrivateLinkScopedResource] - :ivar failover_configuration: Failover configuration on this endpoint. This property is - READ-ONLY. - :vartype failover_configuration: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointFailoverConfiguration - :ivar metadata: Metadata for the resource. This property is READ-ONLY. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetadata - """ - - _validation = { - "location": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "private_link_scoped_resources": {"readonly": True}, - "failover_configuration": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "identity": {"key": "identity", "type": "DataCollectionEndpointResourceIdentity"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionEndpointResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "immutable_id": {"key": "properties.immutableId", "type": "str"}, - "configuration_access": { - "key": "properties.configurationAccess", - "type": "DataCollectionEndpointConfigurationAccess", - }, - "logs_ingestion": {"key": "properties.logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "metrics_ingestion": {"key": "properties.metricsIngestion", "type": "DataCollectionEndpointMetricsIngestion"}, - "network_acls": {"key": "properties.networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "private_link_scoped_resources": { - "key": "properties.privateLinkScopedResources", - "type": "[PrivateLinkScopedResource]", - }, - "failover_configuration": { - "key": "properties.failoverConfiguration", - "type": "DataCollectionEndpointFailoverConfiguration", - }, - "metadata": {"key": "properties.metadata", "type": "DataCollectionEndpointMetadata"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.KnownDataCollectionEndpointResourceKind"]] = None, - identity: Optional["_models.DataCollectionEndpointResourceIdentity"] = None, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - metrics_ingestion: Optional["_models.DataCollectionEndpointMetricsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". - :paramtype kind: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionEndpointResourceKind - :keyword identity: Managed service identity of the resource. - :paramtype identity: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResourceIdentity - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by clients to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointLogsIngestion - :keyword metrics_ingestion: The endpoint used by clients to ingest metrics. - :paramtype metrics_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetricsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointNetworkAcls - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.kind = kind - self.identity = identity - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.immutable_id = immutable_id - self.configuration_access = configuration_access - self.logs_ingestion = logs_ingestion - self.metrics_ingestion = metrics_ingestion - self.network_acls = network_acls - self.provisioning_state = None - self.private_link_scoped_resources = None - self.failover_configuration = None - self.metadata = None - - -class ManagedServiceIdentity(_serialization.Model): - """Managed service identity (system assigned and/or user assigned identities). - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types - are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :ivar user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :keyword user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class DataCollectionEndpointResourceIdentity(ManagedServiceIdentity): - """Managed service identity of the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types - are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :ivar user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :keyword user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - super().__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) - - -class DataCollectionEndpointResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionEndpointResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: list[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection endpoint. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property - is READ-ONLY. - :vartype immutable_id: str - :ivar configuration_access: The endpoint used by clients to access their configuration. - :vartype configuration_access: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointConfigurationAccess - :ivar logs_ingestion: The endpoint used by clients to ingest logs. - :vartype logs_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointLogsIngestion - :ivar metrics_ingestion: The endpoint used by clients to ingest metrics. - :vartype metrics_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetricsIngestion - :ivar network_acls: Network access control rules for the endpoints. - :vartype network_acls: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionEndpointProvisioningState - :ivar private_link_scoped_resources: List of Azure Monitor Private Link Scope Resources to - which this data collection endpoint resource is associated. This property is READ-ONLY. - :vartype private_link_scoped_resources: - list[~azure.mgmt.monitor.v2022_06_01.models.PrivateLinkScopedResource] - :ivar failover_configuration: Failover configuration on this endpoint. This property is - READ-ONLY. - :vartype failover_configuration: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointFailoverConfiguration - :ivar metadata: Metadata for the resource. This property is READ-ONLY. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetadata - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "private_link_scoped_resources": {"readonly": True}, - "failover_configuration": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "configuration_access": {"key": "configurationAccess", "type": "DataCollectionEndpointConfigurationAccess"}, - "logs_ingestion": {"key": "logsIngestion", "type": "DataCollectionEndpointLogsIngestion"}, - "metrics_ingestion": {"key": "metricsIngestion", "type": "DataCollectionEndpointMetricsIngestion"}, - "network_acls": {"key": "networkAcls", "type": "DataCollectionEndpointNetworkAcls"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_link_scoped_resources": {"key": "privateLinkScopedResources", "type": "[PrivateLinkScopedResource]"}, - "failover_configuration": { - "key": "failoverConfiguration", - "type": "DataCollectionEndpointFailoverConfiguration", - }, - "metadata": {"key": "metadata", "type": "DataCollectionEndpointMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - immutable_id: Optional[str] = None, - configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, - metrics_ingestion: Optional["_models.DataCollectionEndpointMetricsIngestion"] = None, - network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection endpoint. - :paramtype description: str - :keyword immutable_id: The immutable ID of this data collection endpoint resource. This - property is READ-ONLY. - :paramtype immutable_id: str - :keyword configuration_access: The endpoint used by clients to access their configuration. - :paramtype configuration_access: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointConfigurationAccess - :keyword logs_ingestion: The endpoint used by clients to ingest logs. - :paramtype logs_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointLogsIngestion - :keyword metrics_ingestion: The endpoint used by clients to ingest metrics. - :paramtype metrics_ingestion: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointMetricsIngestion - :keyword network_acls: Network access control rules for the endpoints. - :paramtype network_acls: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointNetworkAcls - """ - super().__init__( - description=description, - immutable_id=immutable_id, - configuration_access=configuration_access, - logs_ingestion=logs_ingestion, - metrics_ingestion=metrics_ingestion, - network_acls=network_acls, - **kwargs - ) - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class DataCollectionEndpointResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataCollectionRule(_serialization.Model): - """Definition of what monitoring data to collect and where that data should be sent. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :vartype data_collection_endpoint_id: str - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleMetadata - :ivar stream_declarations: Declaration of custom streams used in this rule. - :vartype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.StreamDeclaration] - :ivar data_sources: 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. - :vartype data_sources: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2022_06_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "metadata": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleMetadata"}, - "stream_declarations": {"key": "streamDeclarations", "type": "{StreamDeclaration}"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :paramtype data_collection_endpoint_id: str - :keyword stream_declarations: Declaration of custom streams used in this rule. - :paramtype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.StreamDeclaration] - :keyword data_sources: 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. - :paramtype data_sources: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2022_06_01.models.DataFlow] - """ - super().__init__(**kwargs) - self.description = description - self.immutable_id = None - self.data_collection_endpoint_id = data_collection_endpoint_id - self.metadata = None - self.stream_declarations = stream_declarations - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleAssociation(_serialization.Model): - """Definition of association of a data collection rule with a monitored Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleAssociationProvisioningState - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationMetadata - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleAssociationMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__(**kwargs) - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.data_collection_endpoint_id = data_collection_endpoint_id - self.provisioning_state = None - self.metadata = None - - -class DataCollectionRuleAssociationMetadata(Metadata): - """Metadata about the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioned_by: Azure offering managing this resource on-behalf-of customer. - :vartype provisioned_by: str - :ivar provisioned_by_resource_id: Resource Id of azure offering managing this resource - on-behalf-of customer. - :vartype provisioned_by_resource_id: str - """ - - _validation = { - "provisioned_by": {"readonly": True}, - "provisioned_by_resource_id": {"readonly": True}, - } - - _attribute_map = { - "provisioned_by": {"key": "provisionedBy", "type": "str"}, - "provisioned_by_resource_id": {"key": "provisionedByResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): - """Definition of generic ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResourceSystemData - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleAssociationProvisioningState - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationMetadata - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionRuleAssociationProxyOnlyResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "data_collection_rule_id": {"key": "properties.dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "metadata": {"key": "properties.metadata", "type": "DataCollectionRuleAssociationMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.data_collection_rule_id = data_collection_rule_id - self.data_collection_endpoint_id = data_collection_endpoint_id - self.provisioning_state = None - self.metadata = None - - -class DataCollectionRuleAssociationProxyOnlyResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: - list[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleAssociationProxyOnlyResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: - list[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRuleAssociation): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the association. - :vartype description: str - :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :vartype data_collection_rule_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleAssociationProvisioningState - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationMetadata - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "data_collection_rule_id": {"key": "dataCollectionRuleId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleAssociationMetadata"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_rule_id: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the association. - :paramtype description: str - :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be - associated. - :paramtype data_collection_rule_id: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is - to be associated. - :paramtype data_collection_endpoint_id: str - """ - super().__init__( - description=description, - data_collection_rule_id=data_collection_rule_id, - data_collection_endpoint_id=data_collection_endpoint_id, - **kwargs - ) - - -class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataSourcesSpec(_serialization.Model): - """Specification of data sources that will be collected. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2022_06_01.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2022_06_01.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2022_06_01.models.ExtensionDataSource] - :ivar log_files: The list of Log files source configurations. - :vartype log_files: list[~azure.mgmt.monitor.v2022_06_01.models.LogFilesDataSource] - :ivar iis_logs: The list of IIS logs source configurations. - :vartype iis_logs: list[~azure.mgmt.monitor.v2022_06_01.models.IisLogsDataSource] - :ivar windows_firewall_logs: The list of Windows Firewall logs source configurations. - :vartype windows_firewall_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsFirewallLogsDataSource] - :ivar prometheus_forwarder: The list of Prometheus forwarder data source configurations. - :vartype prometheus_forwarder: - list[~azure.mgmt.monitor.v2022_06_01.models.PrometheusForwarderDataSource] - :ivar platform_telemetry: The list of platform telemetry configurations. - :vartype platform_telemetry: - list[~azure.mgmt.monitor.v2022_06_01.models.PlatformTelemetryDataSource] - :ivar data_imports: Specifications of pull based data sources. - :vartype data_imports: ~azure.mgmt.monitor.v2022_06_01.models.DataSourcesSpecDataImports - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - "log_files": {"key": "logFiles", "type": "[LogFilesDataSource]"}, - "iis_logs": {"key": "iisLogs", "type": "[IisLogsDataSource]"}, - "windows_firewall_logs": {"key": "windowsFirewallLogs", "type": "[WindowsFirewallLogsDataSource]"}, - "prometheus_forwarder": {"key": "prometheusForwarder", "type": "[PrometheusForwarderDataSource]"}, - "platform_telemetry": {"key": "platformTelemetry", "type": "[PlatformTelemetryDataSource]"}, - "data_imports": {"key": "dataImports", "type": "DataSourcesSpecDataImports"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - log_files: Optional[List["_models.LogFilesDataSource"]] = None, - iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, - windows_firewall_logs: Optional[List["_models.WindowsFirewallLogsDataSource"]] = None, - prometheus_forwarder: Optional[List["_models.PrometheusForwarderDataSource"]] = None, - platform_telemetry: Optional[List["_models.PlatformTelemetryDataSource"]] = None, - data_imports: Optional["_models.DataSourcesSpecDataImports"] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2022_06_01.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2022_06_01.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2022_06_01.models.ExtensionDataSource] - :keyword log_files: The list of Log files source configurations. - :paramtype log_files: list[~azure.mgmt.monitor.v2022_06_01.models.LogFilesDataSource] - :keyword iis_logs: The list of IIS logs source configurations. - :paramtype iis_logs: list[~azure.mgmt.monitor.v2022_06_01.models.IisLogsDataSource] - :keyword windows_firewall_logs: The list of Windows Firewall logs source configurations. - :paramtype windows_firewall_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsFirewallLogsDataSource] - :keyword prometheus_forwarder: The list of Prometheus forwarder data source configurations. - :paramtype prometheus_forwarder: - list[~azure.mgmt.monitor.v2022_06_01.models.PrometheusForwarderDataSource] - :keyword platform_telemetry: The list of platform telemetry configurations. - :paramtype platform_telemetry: - list[~azure.mgmt.monitor.v2022_06_01.models.PlatformTelemetryDataSource] - :keyword data_imports: Specifications of pull based data sources. - :paramtype data_imports: ~azure.mgmt.monitor.v2022_06_01.models.DataSourcesSpecDataImports - """ - super().__init__(**kwargs) - self.performance_counters = performance_counters - self.windows_event_logs = windows_event_logs - self.syslog = syslog - self.extensions = extensions - self.log_files = log_files - self.iis_logs = iis_logs - self.windows_firewall_logs = windows_firewall_logs - self.prometheus_forwarder = prometheus_forwarder - self.platform_telemetry = platform_telemetry - self.data_imports = data_imports - - -class DataCollectionRuleDataSources(DataSourcesSpec): - """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. - - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~azure.mgmt.monitor.v2022_06_01.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~azure.mgmt.monitor.v2022_06_01.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~azure.mgmt.monitor.v2022_06_01.models.ExtensionDataSource] - :ivar log_files: The list of Log files source configurations. - :vartype log_files: list[~azure.mgmt.monitor.v2022_06_01.models.LogFilesDataSource] - :ivar iis_logs: The list of IIS logs source configurations. - :vartype iis_logs: list[~azure.mgmt.monitor.v2022_06_01.models.IisLogsDataSource] - :ivar windows_firewall_logs: The list of Windows Firewall logs source configurations. - :vartype windows_firewall_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsFirewallLogsDataSource] - :ivar prometheus_forwarder: The list of Prometheus forwarder data source configurations. - :vartype prometheus_forwarder: - list[~azure.mgmt.monitor.v2022_06_01.models.PrometheusForwarderDataSource] - :ivar platform_telemetry: The list of platform telemetry configurations. - :vartype platform_telemetry: - list[~azure.mgmt.monitor.v2022_06_01.models.PlatformTelemetryDataSource] - :ivar data_imports: Specifications of pull based data sources. - :vartype data_imports: ~azure.mgmt.monitor.v2022_06_01.models.DataSourcesSpecDataImports - """ - - _attribute_map = { - "performance_counters": {"key": "performanceCounters", "type": "[PerfCounterDataSource]"}, - "windows_event_logs": {"key": "windowsEventLogs", "type": "[WindowsEventLogDataSource]"}, - "syslog": {"key": "syslog", "type": "[SyslogDataSource]"}, - "extensions": {"key": "extensions", "type": "[ExtensionDataSource]"}, - "log_files": {"key": "logFiles", "type": "[LogFilesDataSource]"}, - "iis_logs": {"key": "iisLogs", "type": "[IisLogsDataSource]"}, - "windows_firewall_logs": {"key": "windowsFirewallLogs", "type": "[WindowsFirewallLogsDataSource]"}, - "prometheus_forwarder": {"key": "prometheusForwarder", "type": "[PrometheusForwarderDataSource]"}, - "platform_telemetry": {"key": "platformTelemetry", "type": "[PlatformTelemetryDataSource]"}, - "data_imports": {"key": "dataImports", "type": "DataSourcesSpecDataImports"}, - } - - def __init__( - self, - *, - performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, - syslog: Optional[List["_models.SyslogDataSource"]] = None, - extensions: Optional[List["_models.ExtensionDataSource"]] = None, - log_files: Optional[List["_models.LogFilesDataSource"]] = None, - iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, - windows_firewall_logs: Optional[List["_models.WindowsFirewallLogsDataSource"]] = None, - prometheus_forwarder: Optional[List["_models.PrometheusForwarderDataSource"]] = None, - platform_telemetry: Optional[List["_models.PlatformTelemetryDataSource"]] = None, - data_imports: Optional["_models.DataSourcesSpecDataImports"] = None, - **kwargs: Any - ) -> None: - """ - :keyword performance_counters: The list of performance counter data source configurations. - :paramtype performance_counters: - list[~azure.mgmt.monitor.v2022_06_01.models.PerfCounterDataSource] - :keyword windows_event_logs: The list of Windows Event Log data source configurations. - :paramtype windows_event_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsEventLogDataSource] - :keyword syslog: The list of Syslog data source configurations. - :paramtype syslog: list[~azure.mgmt.monitor.v2022_06_01.models.SyslogDataSource] - :keyword extensions: The list of Azure VM extension data source configurations. - :paramtype extensions: list[~azure.mgmt.monitor.v2022_06_01.models.ExtensionDataSource] - :keyword log_files: The list of Log files source configurations. - :paramtype log_files: list[~azure.mgmt.monitor.v2022_06_01.models.LogFilesDataSource] - :keyword iis_logs: The list of IIS logs source configurations. - :paramtype iis_logs: list[~azure.mgmt.monitor.v2022_06_01.models.IisLogsDataSource] - :keyword windows_firewall_logs: The list of Windows Firewall logs source configurations. - :paramtype windows_firewall_logs: - list[~azure.mgmt.monitor.v2022_06_01.models.WindowsFirewallLogsDataSource] - :keyword prometheus_forwarder: The list of Prometheus forwarder data source configurations. - :paramtype prometheus_forwarder: - list[~azure.mgmt.monitor.v2022_06_01.models.PrometheusForwarderDataSource] - :keyword platform_telemetry: The list of platform telemetry configurations. - :paramtype platform_telemetry: - list[~azure.mgmt.monitor.v2022_06_01.models.PlatformTelemetryDataSource] - :keyword data_imports: Specifications of pull based data sources. - :paramtype data_imports: ~azure.mgmt.monitor.v2022_06_01.models.DataSourcesSpecDataImports - """ - super().__init__( - performance_counters=performance_counters, - windows_event_logs=windows_event_logs, - syslog=syslog, - extensions=extensions, - log_files=log_files, - iis_logs=iis_logs, - windows_firewall_logs=windows_firewall_logs, - prometheus_forwarder=prometheus_forwarder, - platform_telemetry=platform_telemetry, - data_imports=data_imports, - **kwargs - ) - - -class DestinationsSpec(_serialization.Model): - """Specification of destinations that can be used in data flows. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: list[~azure.mgmt.monitor.v2022_06_01.models.LogAnalyticsDestination] - :ivar monitoring_accounts: List of monitoring account destinations. - :vartype monitoring_accounts: - list[~azure.mgmt.monitor.v2022_06_01.models.MonitoringAccountDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_06_01.models.DestinationsSpecAzureMonitorMetrics - :ivar event_hubs: List of Event Hubs destinations. - :vartype event_hubs: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDestination] - :ivar event_hubs_direct: List of Event Hubs Direct destinations. - :vartype event_hubs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDirectDestination] - :ivar storage_blobs_direct: List of Storage Blob Direct destinations. To be used only for - sending data directly to store from the agent. - :vartype storage_blobs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - :ivar storage_tables_direct: List of Storage Table Direct destinations. - :vartype storage_tables_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageTableDestination] - :ivar storage_accounts: List of storage accounts destinations. - :vartype storage_accounts: list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "monitoring_accounts": {"key": "monitoringAccounts", "type": "[MonitoringAccountDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - "event_hubs": {"key": "eventHubs", "type": "[EventHubDestination]"}, - "event_hubs_direct": {"key": "eventHubsDirect", "type": "[EventHubDirectDestination]"}, - "storage_blobs_direct": {"key": "storageBlobsDirect", "type": "[StorageBlobDestination]"}, - "storage_tables_direct": {"key": "storageTablesDirect", "type": "[StorageTableDestination]"}, - "storage_accounts": {"key": "storageAccounts", "type": "[StorageBlobDestination]"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - monitoring_accounts: Optional[List["_models.MonitoringAccountDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - event_hubs: Optional[List["_models.EventHubDestination"]] = None, - event_hubs_direct: Optional[List["_models.EventHubDirectDestination"]] = None, - storage_blobs_direct: Optional[List["_models.StorageBlobDestination"]] = None, - storage_tables_direct: Optional[List["_models.StorageTableDestination"]] = None, - storage_accounts: Optional[List["_models.StorageBlobDestination"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: list[~azure.mgmt.monitor.v2022_06_01.models.LogAnalyticsDestination] - :keyword monitoring_accounts: List of monitoring account destinations. - :paramtype monitoring_accounts: - list[~azure.mgmt.monitor.v2022_06_01.models.MonitoringAccountDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_06_01.models.DestinationsSpecAzureMonitorMetrics - :keyword event_hubs: List of Event Hubs destinations. - :paramtype event_hubs: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDestination] - :keyword event_hubs_direct: List of Event Hubs Direct destinations. - :paramtype event_hubs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDirectDestination] - :keyword storage_blobs_direct: List of Storage Blob Direct destinations. To be used only for - sending data directly to store from the agent. - :paramtype storage_blobs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - :keyword storage_tables_direct: List of Storage Table Direct destinations. - :paramtype storage_tables_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageTableDestination] - :keyword storage_accounts: List of storage accounts destinations. - :paramtype storage_accounts: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - """ - super().__init__(**kwargs) - self.log_analytics = log_analytics - self.monitoring_accounts = monitoring_accounts - self.azure_monitor_metrics = azure_monitor_metrics - self.event_hubs = event_hubs - self.event_hubs_direct = event_hubs_direct - self.storage_blobs_direct = storage_blobs_direct - self.storage_tables_direct = storage_tables_direct - self.storage_accounts = storage_accounts - - -class DataCollectionRuleDestinations(DestinationsSpec): - """The specification of destinations. - - :ivar log_analytics: List of Log Analytics destinations. - :vartype log_analytics: list[~azure.mgmt.monitor.v2022_06_01.models.LogAnalyticsDestination] - :ivar monitoring_accounts: List of monitoring account destinations. - :vartype monitoring_accounts: - list[~azure.mgmt.monitor.v2022_06_01.models.MonitoringAccountDestination] - :ivar azure_monitor_metrics: Azure Monitor Metrics destination. - :vartype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_06_01.models.DestinationsSpecAzureMonitorMetrics - :ivar event_hubs: List of Event Hubs destinations. - :vartype event_hubs: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDestination] - :ivar event_hubs_direct: List of Event Hubs Direct destinations. - :vartype event_hubs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDirectDestination] - :ivar storage_blobs_direct: List of Storage Blob Direct destinations. To be used only for - sending data directly to store from the agent. - :vartype storage_blobs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - :ivar storage_tables_direct: List of Storage Table Direct destinations. - :vartype storage_tables_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageTableDestination] - :ivar storage_accounts: List of storage accounts destinations. - :vartype storage_accounts: list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - """ - - _attribute_map = { - "log_analytics": {"key": "logAnalytics", "type": "[LogAnalyticsDestination]"}, - "monitoring_accounts": {"key": "monitoringAccounts", "type": "[MonitoringAccountDestination]"}, - "azure_monitor_metrics": {"key": "azureMonitorMetrics", "type": "DestinationsSpecAzureMonitorMetrics"}, - "event_hubs": {"key": "eventHubs", "type": "[EventHubDestination]"}, - "event_hubs_direct": {"key": "eventHubsDirect", "type": "[EventHubDirectDestination]"}, - "storage_blobs_direct": {"key": "storageBlobsDirect", "type": "[StorageBlobDestination]"}, - "storage_tables_direct": {"key": "storageTablesDirect", "type": "[StorageTableDestination]"}, - "storage_accounts": {"key": "storageAccounts", "type": "[StorageBlobDestination]"}, - } - - def __init__( - self, - *, - log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, - monitoring_accounts: Optional[List["_models.MonitoringAccountDestination"]] = None, - azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - event_hubs: Optional[List["_models.EventHubDestination"]] = None, - event_hubs_direct: Optional[List["_models.EventHubDirectDestination"]] = None, - storage_blobs_direct: Optional[List["_models.StorageBlobDestination"]] = None, - storage_tables_direct: Optional[List["_models.StorageTableDestination"]] = None, - storage_accounts: Optional[List["_models.StorageBlobDestination"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_analytics: List of Log Analytics destinations. - :paramtype log_analytics: list[~azure.mgmt.monitor.v2022_06_01.models.LogAnalyticsDestination] - :keyword monitoring_accounts: List of monitoring account destinations. - :paramtype monitoring_accounts: - list[~azure.mgmt.monitor.v2022_06_01.models.MonitoringAccountDestination] - :keyword azure_monitor_metrics: Azure Monitor Metrics destination. - :paramtype azure_monitor_metrics: - ~azure.mgmt.monitor.v2022_06_01.models.DestinationsSpecAzureMonitorMetrics - :keyword event_hubs: List of Event Hubs destinations. - :paramtype event_hubs: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDestination] - :keyword event_hubs_direct: List of Event Hubs Direct destinations. - :paramtype event_hubs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.EventHubDirectDestination] - :keyword storage_blobs_direct: List of Storage Blob Direct destinations. To be used only for - sending data directly to store from the agent. - :paramtype storage_blobs_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - :keyword storage_tables_direct: List of Storage Table Direct destinations. - :paramtype storage_tables_direct: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageTableDestination] - :keyword storage_accounts: List of storage accounts destinations. - :paramtype storage_accounts: - list[~azure.mgmt.monitor.v2022_06_01.models.StorageBlobDestination] - """ - super().__init__( - log_analytics=log_analytics, - monitoring_accounts=monitoring_accounts, - azure_monitor_metrics=azure_monitor_metrics, - event_hubs=event_hubs, - event_hubs_direct=event_hubs_direct, - storage_blobs_direct=storage_blobs_direct, - storage_tables_direct=storage_tables_direct, - storage_accounts=storage_accounts, - **kwargs - ) - - -class DataCollectionRuleMetadata(Metadata): - """Metadata about the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioned_by: Azure offering managing this resource on-behalf-of customer. - :vartype provisioned_by: str - :ivar provisioned_by_resource_id: Resource Id of azure offering managing this resource - on-behalf-of customer. - :vartype provisioned_by_resource_id: str - """ - - _validation = { - "provisioned_by": {"readonly": True}, - "provisioned_by_resource_id": {"readonly": True}, - } - - _attribute_map = { - "provisioned_by": {"key": "provisionedBy", "type": "str"}, - "provisioned_by_resource_id": {"key": "provisionedByResourceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - -class DataCollectionRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Known values are: "Linux" and "Windows". - :vartype kind: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleResourceKind - :ivar identity: Managed service identity of the resource. - :vartype identity: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResourceIdentity - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResourceSystemData - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :vartype data_collection_endpoint_id: str - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleMetadata - :ivar stream_declarations: Declaration of custom streams used in this rule. - :vartype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.StreamDeclaration] - :ivar data_sources: 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. - :vartype data_sources: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2022_06_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "location": {"required": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "immutable_id": {"readonly": True}, - "metadata": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "kind": {"key": "kind", "type": "str"}, - "identity": {"key": "identity", "type": "DataCollectionRuleResourceIdentity"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "DataCollectionRuleResourceSystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "immutable_id": {"key": "properties.immutableId", "type": "str"}, - "data_collection_endpoint_id": {"key": "properties.dataCollectionEndpointId", "type": "str"}, - "metadata": {"key": "properties.metadata", "type": "DataCollectionRuleMetadata"}, - "stream_declarations": {"key": "properties.streamDeclarations", "type": "{StreamDeclaration}"}, - "data_sources": {"key": "properties.dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "properties.destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "properties.dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.KnownDataCollectionRuleResourceKind"]] = None, - identity: Optional["_models.DataCollectionRuleResourceIdentity"] = None, - description: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Known values are: "Linux" and "Windows". - :paramtype kind: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleResourceKind - :keyword identity: Managed service identity of the resource. - :paramtype identity: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResourceIdentity - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :paramtype data_collection_endpoint_id: str - :keyword stream_declarations: Declaration of custom streams used in this rule. - :paramtype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.StreamDeclaration] - :keyword data_sources: 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. - :paramtype data_sources: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2022_06_01.models.DataFlow] - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - self.kind = kind - self.identity = identity - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = description - self.immutable_id = None - self.data_collection_endpoint_id = data_collection_endpoint_id - self.metadata = None - self.stream_declarations = stream_declarations - self.data_sources = data_sources - self.destinations = destinations - self.data_flows = data_flows - self.provisioning_state = None - - -class DataCollectionRuleResourceIdentity(ManagedServiceIdentity): - """Managed service identity of the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types - are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :ivar user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :keyword user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - super().__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) - - -class DataCollectionRuleResourceListResult(_serialization.Model): - """A pageable list of resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: A list of resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataCollectionRuleResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: A list of resources. Required. - :paramtype value: list[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DataCollectionRuleResourceProperties(DataCollectionRule): - """Resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the data collection rule. - :vartype description: str - :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. - :vartype immutable_id: str - :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :vartype data_collection_endpoint_id: str - :ivar metadata: Metadata about the resource. - :vartype metadata: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleMetadata - :ivar stream_declarations: Declaration of custom streams used in this rule. - :vartype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.StreamDeclaration] - :ivar data_sources: 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. - :vartype data_sources: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDataSources - :ivar destinations: The specification of destinations. - :vartype destinations: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDestinations - :ivar data_flows: The specification of data flows. - :vartype data_flows: list[~azure.mgmt.monitor.v2022_06_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - "immutable_id": {"readonly": True}, - "metadata": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "immutable_id": {"key": "immutableId", "type": "str"}, - "data_collection_endpoint_id": {"key": "dataCollectionEndpointId", "type": "str"}, - "metadata": {"key": "metadata", "type": "DataCollectionRuleMetadata"}, - "stream_declarations": {"key": "streamDeclarations", "type": "{StreamDeclaration}"}, - "data_sources": {"key": "dataSources", "type": "DataCollectionRuleDataSources"}, - "destinations": {"key": "destinations", "type": "DataCollectionRuleDestinations"}, - "data_flows": {"key": "dataFlows", "type": "[DataFlow]"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, - data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, - destinations: Optional["_models.DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the data collection rule. - :paramtype description: str - :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that this - rule can be used with. - :paramtype data_collection_endpoint_id: str - :keyword stream_declarations: Declaration of custom streams used in this rule. - :paramtype stream_declarations: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.StreamDeclaration] - :keyword data_sources: 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. - :paramtype data_sources: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDataSources - :keyword destinations: The specification of destinations. - :paramtype destinations: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleDestinations - :keyword data_flows: The specification of data flows. - :paramtype data_flows: list[~azure.mgmt.monitor.v2022_06_01.models.DataFlow] - """ - super().__init__( - description=description, - data_collection_endpoint_id=data_collection_endpoint_id, - stream_declarations=stream_declarations, - data_sources=data_sources, - destinations=destinations, - data_flows=data_flows, - **kwargs - ) - - -class DataCollectionRuleResourceSystemData(SystemData): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_06_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__( - created_by=created_by, - created_by_type=created_by_type, - created_at=created_at, - last_modified_by=last_modified_by, - last_modified_by_type=last_modified_by_type, - last_modified_at=last_modified_at, - **kwargs - ) - - -class DataFlow(_serialization.Model): - """Definition of which streams are sent to which destinations. - - :ivar streams: List of streams for this data flow. - :vartype streams: list[str or ~azure.mgmt.monitor.v2022_06_01.models.KnownDataFlowStreams] - :ivar destinations: List of destinations for this data flow. - :vartype destinations: list[str] - :ivar transform_kql: The KQL query to transform stream data. - :vartype transform_kql: str - :ivar output_stream: The output stream of the transform. Only required if the transform changes - data to a different stream. - :vartype output_stream: str - :ivar built_in_transform: The builtIn transform to transform stream data. - :vartype built_in_transform: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "destinations": {"key": "destinations", "type": "[str]"}, - "transform_kql": {"key": "transformKql", "type": "str"}, - "output_stream": {"key": "outputStream", "type": "str"}, - "built_in_transform": {"key": "builtInTransform", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, - destinations: Optional[List[str]] = None, - transform_kql: Optional[str] = None, - output_stream: Optional[str] = None, - built_in_transform: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: List of streams for this data flow. - :paramtype streams: list[str or ~azure.mgmt.monitor.v2022_06_01.models.KnownDataFlowStreams] - :keyword destinations: List of destinations for this data flow. - :paramtype destinations: list[str] - :keyword transform_kql: The KQL query to transform stream data. - :paramtype transform_kql: str - :keyword output_stream: The output stream of the transform. Only required if the transform - changes data to a different stream. - :paramtype output_stream: str - :keyword built_in_transform: The builtIn transform to transform stream data. - :paramtype built_in_transform: str - """ - super().__init__(**kwargs) - self.streams = streams - self.destinations = destinations - self.transform_kql = transform_kql - self.output_stream = output_stream - self.built_in_transform = built_in_transform - - -class DataImportSources(_serialization.Model): - """DataImportSources. - - :ivar event_hub: Definition of Event Hub configuration. - :vartype event_hub: ~azure.mgmt.monitor.v2022_06_01.models.DataImportSourcesEventHub - """ - - _attribute_map = { - "event_hub": {"key": "eventHub", "type": "DataImportSourcesEventHub"}, - } - - def __init__(self, *, event_hub: Optional["_models.DataImportSourcesEventHub"] = None, **kwargs: Any) -> None: - """ - :keyword event_hub: Definition of Event Hub configuration. - :paramtype event_hub: ~azure.mgmt.monitor.v2022_06_01.models.DataImportSourcesEventHub - """ - super().__init__(**kwargs) - self.event_hub = event_hub - - -class EventHubDataSource(_serialization.Model): - """EventHubDataSource. - - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - :ivar consumer_group: Event Hub consumer group name. - :vartype consumer_group: str - :ivar stream: The stream to collect from EventHub. - :vartype stream: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "consumer_group": {"key": "consumerGroup", "type": "str"}, - "stream": {"key": "stream", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - consumer_group: Optional[str] = None, - stream: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - :keyword consumer_group: Event Hub consumer group name. - :paramtype consumer_group: str - :keyword stream: The stream to collect from EventHub. - :paramtype stream: str - """ - super().__init__(**kwargs) - self.name = name - self.consumer_group = consumer_group - self.stream = stream - - -class DataImportSourcesEventHub(EventHubDataSource): - """Definition of Event Hub configuration. - - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - :ivar consumer_group: Event Hub consumer group name. - :vartype consumer_group: str - :ivar stream: The stream to collect from EventHub. - :vartype stream: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "consumer_group": {"key": "consumerGroup", "type": "str"}, - "stream": {"key": "stream", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - consumer_group: Optional[str] = None, - stream: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - :keyword consumer_group: Event Hub consumer group name. - :paramtype consumer_group: str - :keyword stream: The stream to collect from EventHub. - :paramtype stream: str - """ - super().__init__(name=name, consumer_group=consumer_group, stream=stream, **kwargs) - - -class DataSourcesSpecDataImports(DataImportSources): - """Specifications of pull based data sources. - - :ivar event_hub: Definition of Event Hub configuration. - :vartype event_hub: ~azure.mgmt.monitor.v2022_06_01.models.DataImportSourcesEventHub - """ - - _attribute_map = { - "event_hub": {"key": "eventHub", "type": "DataImportSourcesEventHub"}, - } - - def __init__(self, *, event_hub: Optional["_models.DataImportSourcesEventHub"] = None, **kwargs: Any) -> None: - """ - :keyword event_hub: Definition of Event Hub configuration. - :paramtype event_hub: ~azure.mgmt.monitor.v2022_06_01.models.DataImportSourcesEventHub - """ - super().__init__(event_hub=event_hub, **kwargs) - - -class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): - """Azure Monitor Metrics destination. - - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(name=name, **kwargs) - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2022_06_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.use_common_alert_schema = use_common_alert_schema - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2022_06_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.monitor.v2022_06_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ErrorResponseCommonV2(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2022_06_01.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2022_06_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class EventHubDestination(_serialization.Model): - """EventHubDestination. - - :ivar event_hub_resource_id: The resource ID of the event hub. - :vartype event_hub_resource_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "event_hub_resource_id": {"key": "eventHubResourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, *, event_hub_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword event_hub_resource_id: The resource ID of the event hub. - :paramtype event_hub_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.event_hub_resource_id = event_hub_resource_id - self.name = name - - -class EventHubDirectDestination(_serialization.Model): - """EventHubDirectDestination. - - :ivar event_hub_resource_id: The resource ID of the event hub. - :vartype event_hub_resource_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "event_hub_resource_id": {"key": "eventHubResourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, *, event_hub_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword event_hub_resource_id: The resource ID of the event hub. - :paramtype event_hub_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.event_hub_resource_id = event_hub_resource_id - self.name = name - - -class EventHubReceiver(_serialization.Model): - """An Event hub receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar event_hub_name_space: The Event Hub namespace. Required. - :vartype event_hub_name_space: str - :ivar event_hub_name: The name of the specific Event Hub queue. Required. - :vartype event_hub_name: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar tenant_id: The tenant Id for the subscription containing this event hub. - :vartype tenant_id: str - :ivar subscription_id: The Id for the subscription containing this event hub. Required. - :vartype subscription_id: str - """ - - _validation = { - "name": {"required": True}, - "event_hub_name_space": {"required": True}, - "event_hub_name": {"required": True}, - "subscription_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, - "event_hub_name": {"key": "eventHubName", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - event_hub_name_space: str, - event_hub_name: str, - subscription_id: str, - use_common_alert_schema: bool = False, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword event_hub_name_space: The Event Hub namespace. Required. - :paramtype event_hub_name_space: str - :keyword event_hub_name: The name of the specific Event Hub queue. Required. - :paramtype event_hub_name: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword tenant_id: The tenant Id for the subscription containing this event hub. - :paramtype tenant_id: str - :keyword subscription_id: The Id for the subscription containing this event hub. Required. - :paramtype subscription_id: str - """ - super().__init__(**kwargs) - self.name = name - self.event_hub_name_space = event_hub_name_space - self.event_hub_name = event_hub_name - self.use_common_alert_schema = use_common_alert_schema - self.tenant_id = tenant_id - self.subscription_id = subscription_id - - -class ExtensionDataSource(_serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with - the Azure Monitor Agent. - Collected from either Windows and Linux machines, depending on which extension is defined. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownExtensionDataSourceStreams] - :ivar extension_name: The name of the VM extension. Required. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: JSON - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "extension_name": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "extension_name": {"key": "extensionName", "type": "str"}, - "extension_settings": {"key": "extensionSettings", "type": "object"}, - "input_data_sources": {"key": "inputDataSources", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - extension_name: str, - streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, - extension_settings: Optional[JSON] = None, - input_data_sources: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownExtensionDataSourceStreams] - :keyword extension_name: The name of the VM extension. Required. - :paramtype extension_name: str - :keyword extension_settings: The extension settings. The format is specific for particular - extension. - :paramtype extension_settings: JSON - :keyword input_data_sources: The list of data sources this extension needs data from. - :paramtype input_data_sources: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.extension_name = extension_name - self.extension_settings = extension_settings - self.input_data_sources = input_data_sources - self.name = name - - -class IisLogsDataSource(_serialization.Model): - """Enables IIS logs to be collected by this data collection rule. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: IIS streams. Required. - :vartype streams: list[str] - :ivar log_directories: Absolute paths file location. - :vartype log_directories: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "streams": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "log_directories": {"key": "logDirectories", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: List[str], - log_directories: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: IIS streams. Required. - :paramtype streams: list[str] - :keyword log_directories: Absolute paths file location. - :paramtype log_directories: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.log_directories = log_directories - self.name = name - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LocationSpec(_serialization.Model): - """LocationSpec. - - :ivar location: Name of location. - :vartype location: str - :ivar provisioning_status: The resource provisioning state in this location. Known values are: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :vartype provisioning_status: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownLocationSpecProvisioningStatus - """ - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "provisioning_status": {"key": "provisioningStatus", "type": "str"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - provisioning_status: Optional[Union[str, "_models.KnownLocationSpecProvisioningStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Name of location. - :paramtype location: str - :keyword provisioning_status: The resource provisioning state in this location. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". - :paramtype provisioning_status: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownLocationSpecProvisioningStatus - """ - super().__init__(**kwargs) - self.location = location - self.provisioning_status = provisioning_status - - -class LogAnalyticsDestination(_serialization.Model): - """Log Analytics destination. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. - :vartype workspace_resource_id: str - :ivar workspace_id: The Customer ID of the Log Analytics workspace. - :vartype workspace_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "workspace_id": {"readonly": True}, - } - - _attribute_map = { - "workspace_resource_id": {"key": "workspaceResourceId", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. - :paramtype workspace_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.workspace_resource_id = workspace_resource_id - self.workspace_id = None - self.name = name - - -class LogFilesDataSource(_serialization.Model): - """Definition of which custom log files will be collected by this data collection rule. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data source. Required. - :vartype streams: list[str] - :ivar file_patterns: File Patterns where the log files are located. Required. - :vartype file_patterns: list[str] - :ivar format: The data format of the log files. Required. "text" - :vartype format: str or ~azure.mgmt.monitor.v2022_06_01.models.KnownLogFilesDataSourceFormat - :ivar settings: The log files specific settings. - :vartype settings: ~azure.mgmt.monitor.v2022_06_01.models.LogFilesDataSourceSettings - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "streams": {"required": True}, - "file_patterns": {"required": True}, - "format": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "file_patterns": {"key": "filePatterns", "type": "[str]"}, - "format": {"key": "format", "type": "str"}, - "settings": {"key": "settings", "type": "LogFilesDataSourceSettings"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: List[str], - file_patterns: List[str], - format: Union[str, "_models.KnownLogFilesDataSourceFormat"], - settings: Optional["_models.LogFilesDataSourceSettings"] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data source. Required. - :paramtype streams: list[str] - :keyword file_patterns: File Patterns where the log files are located. Required. - :paramtype file_patterns: list[str] - :keyword format: The data format of the log files. Required. "text" - :paramtype format: str or ~azure.mgmt.monitor.v2022_06_01.models.KnownLogFilesDataSourceFormat - :keyword settings: The log files specific settings. - :paramtype settings: ~azure.mgmt.monitor.v2022_06_01.models.LogFilesDataSourceSettings - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.file_patterns = file_patterns - self.format = format - self.settings = settings - self.name = name - - -class LogFileSettings(_serialization.Model): - """Settings for different log file formats. - - :ivar text: Text settings. - :vartype text: ~azure.mgmt.monitor.v2022_06_01.models.LogFileSettingsText - """ - - _attribute_map = { - "text": {"key": "text", "type": "LogFileSettingsText"}, - } - - def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs: Any) -> None: - """ - :keyword text: Text settings. - :paramtype text: ~azure.mgmt.monitor.v2022_06_01.models.LogFileSettingsText - """ - super().__init__(**kwargs) - self.text = text - - -class LogFilesDataSourceSettings(LogFileSettings): - """The log files specific settings. - - :ivar text: Text settings. - :vartype text: ~azure.mgmt.monitor.v2022_06_01.models.LogFileSettingsText - """ - - _attribute_map = { - "text": {"key": "text", "type": "LogFileSettingsText"}, - } - - def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs: Any) -> None: - """ - :keyword text: Text settings. - :paramtype text: ~azure.mgmt.monitor.v2022_06_01.models.LogFileSettingsText - """ - super().__init__(text=text, **kwargs) - - -class LogFileTextSettings(_serialization.Model): - """Settings for text log files. - - All required parameters must be populated in order to send to Azure. - - :ivar record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :vartype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - - _validation = { - "record_start_timestamp_format": {"required": True}, - } - - _attribute_map = { - "record_start_timestamp_format": {"key": "recordStartTimestampFormat", "type": "str"}, - } - - def __init__( - self, - *, - record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], - **kwargs: Any - ) -> None: - """ - :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :paramtype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - super().__init__(**kwargs) - self.record_start_timestamp_format = record_start_timestamp_format - - -class LogFileSettingsText(LogFileTextSettings): - """Text settings. - - All required parameters must be populated in order to send to Azure. - - :ivar record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :vartype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - - _validation = { - "record_start_timestamp_format": {"required": True}, - } - - _attribute_map = { - "record_start_timestamp_format": {"key": "recordStartTimestampFormat", "type": "str"}, - } - - def __init__( - self, - *, - record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], - **kwargs: Any - ) -> None: - """ - :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known - values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY - HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", - and "yyyy-MM-ddTHH:mm:ssK". - :paramtype record_start_timestamp_format: str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownLogFileTextSettingsRecordStartTimestampFormat - """ - super().__init__(record_start_timestamp_format=record_start_timestamp_format, **kwargs) - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - self.use_common_alert_schema = use_common_alert_schema - - -class MonitoringAccountDestination(_serialization.Model): - """Monitoring account destination. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar account_resource_id: The resource ID of the monitoring account. - :vartype account_resource_id: str - :ivar account_id: The immutable ID of the account. - :vartype account_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "account_id": {"readonly": True}, - } - - _attribute_map = { - "account_resource_id": {"key": "accountResourceId", "type": "str"}, - "account_id": {"key": "accountId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, account_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword account_resource_id: The resource ID of the monitoring account. - :paramtype account_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.account_resource_id = account_resource_id - self.account_id = None - self.name = name - - -class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The request body which contain contact detail metadata. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :vartype alert_type: str - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubReceiver] - """ - - _validation = { - "alert_type": {"required": True, "max_length": 30}, - } - - _attribute_map = { - "alert_type": {"key": "alertType", "type": "str"}, - "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, - "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - alert_type: str, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :paramtype alert_type: str - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2022_06_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2022_06_01.models.EventHubReceiver] - """ - super().__init__(**kwargs) - self.alert_type = alert_type - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class PerfCounterDataSource(_serialization.Model): - """Definition of which performance counters will be collected and how they will be collected by - this data collection rule. - Collected from both Windows and Linux machines where the counter is present. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: 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'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "sampling_frequency_in_seconds": {"key": "samplingFrequencyInSeconds", "type": "int"}, - "counter_specifiers": {"key": "counterSpecifiers", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownPerfCounterDataSourceStreams"]]] = None, - sampling_frequency_in_seconds: Optional[int] = None, - counter_specifiers: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPerfCounterDataSourceStreams] - :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :paramtype sampling_frequency_in_seconds: int - :keyword counter_specifiers: 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'. - :paramtype counter_specifiers: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.sampling_frequency_in_seconds = sampling_frequency_in_seconds - self.counter_specifiers = counter_specifiers - self.name = name - - -class PlatformTelemetryDataSource(_serialization.Model): - """Definition of platform telemetry data source configuration. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: List of platform telemetry streams to collect. Required. - :vartype streams: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "streams": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, streams: List[str], name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword streams: List of platform telemetry streams to collect. Required. - :paramtype streams: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.name = name - - -class PrivateLinkScopedResource(_serialization.Model): - """PrivateLinkScopedResource. - - :ivar resource_id: The resourceId of the Azure Monitor Private Link Scope Scoped Resource - through which this DCE is associated with a Azure Monitor Private Link Scope. - :vartype resource_id: str - :ivar scope_id: The immutableId of the Azure Monitor Private Link Scope Resource to which the - association is. - :vartype scope_id: str - """ - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - "scope_id": {"key": "scopeId", "type": "str"}, - } - - def __init__(self, *, resource_id: Optional[str] = None, scope_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword resource_id: The resourceId of the Azure Monitor Private Link Scope Scoped Resource - through which this DCE is associated with a Azure Monitor Private Link Scope. - :paramtype resource_id: str - :keyword scope_id: The immutableId of the Azure Monitor Private Link Scope Resource to which - the association is. - :paramtype scope_id: str - """ - super().__init__(**kwargs) - self.resource_id = resource_id - self.scope_id = scope_id - - -class PrometheusForwarderDataSource(_serialization.Model): - """Definition of Prometheus metrics forwarding configuration. - - :ivar streams: List of streams that this data source will be sent to. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPrometheusForwarderDataSourceStreams] - :ivar label_include_filter: The list of label inclusion filters in the form of label - "name-value" pairs. - Currently only one label is supported: 'microsoft_metrics_include_label'. - Label values are matched case-insensitively. - :vartype label_include_filter: dict[str, str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "label_include_filter": {"key": "labelIncludeFilter", "type": "{str}"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownPrometheusForwarderDataSourceStreams"]]] = None, - label_include_filter: Optional[Dict[str, str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: List of streams that this data source will be sent to. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownPrometheusForwarderDataSourceStreams] - :keyword label_include_filter: The list of label inclusion filters in the form of label - "name-value" pairs. - Currently only one label is supported: 'microsoft_metrics_include_label'. - Label values are matched case-insensitively. - :paramtype label_include_filter: dict[str, str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.label_include_filter = label_include_filter - self.name = name - - -class ResourceForUpdate(_serialization.Model): - """Definition of ARM tracked top level resource properties for update operation. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar identity: Managed Service Identity. - :vartype identity: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdateIdentity - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "ResourceForUpdateIdentity"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.ResourceForUpdateIdentity"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: Managed Service Identity. - :paramtype identity: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdateIdentity - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - - -class ResourceForUpdateIdentity(ManagedServiceIdentity): - """Managed Service Identity. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types - are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :ivar user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.monitor.v2022_06_01.models.ManagedServiceIdentityType - :keyword user_assigned_identities: The set of user assigned identities associated with the - resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. - The dictionary values can be empty objects ({}) in requests. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_06_01.models.UserAssignedIdentity] - """ - super().__init__(type=type, user_assigned_identities=user_assigned_identities, **kwargs) - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2022_06_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class StorageBlobDestination(_serialization.Model): - """StorageBlobDestination. - - :ivar container_name: The container name of the Storage Blob. - :vartype container_name: str - :ivar storage_account_resource_id: The resource ID of the storage account. - :vartype storage_account_resource_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "container_name": {"key": "containerName", "type": "str"}, - "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - container_name: Optional[str] = None, - storage_account_resource_id: Optional[str] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword container_name: The container name of the Storage Blob. - :paramtype container_name: str - :keyword storage_account_resource_id: The resource ID of the storage account. - :paramtype storage_account_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.container_name = container_name - self.storage_account_resource_id = storage_account_resource_id - self.name = name - - -class StorageTableDestination(_serialization.Model): - """StorageTableDestination. - - :ivar table_name: The name of the Storage Table. - :vartype table_name: str - :ivar storage_account_resource_id: The resource ID of the storage account. - :vartype storage_account_resource_id: str - :ivar name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "table_name": {"key": "tableName", "type": "str"}, - "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - table_name: Optional[str] = None, - storage_account_resource_id: Optional[str] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword table_name: The name of the Storage Table. - :paramtype table_name: str - :keyword storage_account_resource_id: The resource ID of the storage account. - :paramtype storage_account_resource_id: str - :keyword name: A friendly name for the destination. - This name should be unique across all destinations (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.table_name = table_name - self.storage_account_resource_id = storage_account_resource_id - self.name = name - - -class StreamDeclaration(_serialization.Model): - """Declaration of a custom stream. - - :ivar columns: List of columns used by data in this stream. - :vartype columns: list[~azure.mgmt.monitor.v2022_06_01.models.ColumnDefinition] - """ - - _attribute_map = { - "columns": {"key": "columns", "type": "[ColumnDefinition]"}, - } - - def __init__(self, *, columns: Optional[List["_models.ColumnDefinition"]] = None, **kwargs: Any) -> None: - """ - :keyword columns: List of columns used by data in this stream. - :paramtype columns: list[~azure.mgmt.monitor.v2022_06_01.models.ColumnDefinition] - """ - super().__init__(**kwargs) - self.columns = columns - - -class SyslogDataSource(_serialization.Model): - """Definition of which syslog data will be collected and how it will be collected. - Only collected from Linux machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "facility_names": {"key": "facilityNames", "type": "[str]"}, - "log_levels": {"key": "logLevels", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownSyslogDataSourceStreams"]]] = None, - facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, - log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownSyslogDataSourceStreams] - :keyword facility_names: The list of facility names. - :paramtype facility_names: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownSyslogDataSourceFacilityNames] - :keyword log_levels: The log levels to collect. - :paramtype log_levels: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownSyslogDataSourceLogLevels] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.facility_names = facility_names - self.log_levels = log_levels - self.name = name - - -class TestNotificationDetailsResponse(_serialization.Model): - """The details of the test notification results. - - All required parameters must be populated in order to send to Azure. - - :ivar context: The context info. - :vartype context: ~azure.mgmt.monitor.v2022_06_01.models.Context - :ivar state: The overall state. Required. - :vartype state: str - :ivar completed_time: The completed time. - :vartype completed_time: str - :ivar created_time: The created time. - :vartype created_time: str - :ivar action_details: The list of action detail. - :vartype action_details: list[~azure.mgmt.monitor.v2022_06_01.models.ActionDetail] - """ - - _validation = { - "state": {"required": True}, - } - - _attribute_map = { - "context": {"key": "context", "type": "Context"}, - "state": {"key": "state", "type": "str"}, - "completed_time": {"key": "completedTime", "type": "str"}, - "created_time": {"key": "createdTime", "type": "str"}, - "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, - } - - def __init__( - self, - *, - state: str, - context: Optional["_models.Context"] = None, - completed_time: Optional[str] = None, - created_time: Optional[str] = None, - action_details: Optional[List["_models.ActionDetail"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context: The context info. - :paramtype context: ~azure.mgmt.monitor.v2022_06_01.models.Context - :keyword state: The overall state. Required. - :paramtype state: str - :keyword completed_time: The completed time. - :paramtype completed_time: str - :keyword created_time: The created time. - :paramtype created_time: str - :keyword action_details: The list of action detail. - :paramtype action_details: list[~azure.mgmt.monitor.v2022_06_01.models.ActionDetail] - """ - super().__init__(**kwargs) - self.context = context - self.state = state - self.completed_time = completed_time - self.created_time = created_time - self.action_details = action_details - - -class UserAssignedIdentity(_serialization.Model): - """User assigned identity properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of the assigned identity. - :vartype principal_id: str - :ivar client_id: The client ID of the assigned identity. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar use_aad_auth: Indicates whether or not use AAD authentication. - :vartype use_aad_auth: bool - :ivar object_id: Indicates the webhook app object Id for aad auth. - :vartype object_id: str - :ivar identifier_uri: Indicates the identifier uri for aad auth. - :vartype identifier_uri: str - :ivar tenant_id: Indicates the tenant id for aad auth. - :vartype tenant_id: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, - "object_id": {"key": "objectId", "type": "str"}, - "identifier_uri": {"key": "identifierUri", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - service_uri: str, - use_common_alert_schema: bool = False, - use_aad_auth: bool = False, - object_id: Optional[str] = None, - identifier_uri: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword use_aad_auth: Indicates whether or not use AAD authentication. - :paramtype use_aad_auth: bool - :keyword object_id: Indicates the webhook app object Id for aad auth. - :paramtype object_id: str - :keyword identifier_uri: Indicates the identifier uri for aad auth. - :paramtype identifier_uri: str - :keyword tenant_id: Indicates the tenant id for aad auth. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - self.use_aad_auth = use_aad_auth - self.object_id = object_id - self.identifier_uri = identifier_uri - self.tenant_id = tenant_id - - -class WindowsEventLogDataSource(_serialization.Model): - """Definition of which Windows Event Log events will be collected and how they will be collected. - Only collected from Windows machines. - - :ivar streams: 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. - :vartype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "x_path_queries": {"key": "xPathQueries", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, - x_path_queries: Optional[List[str]] = None, - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword streams: 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. - :paramtype streams: list[str or - ~azure.mgmt.monitor.v2022_06_01.models.KnownWindowsEventLogDataSourceStreams] - :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. - :paramtype x_path_queries: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.x_path_queries = x_path_queries - self.name = name - - -class WindowsFirewallLogsDataSource(_serialization.Model): - """Enables Firewall logs to be collected by this data collection rule. - - All required parameters must be populated in order to send to Azure. - - :ivar streams: Firewall logs streams. Required. - :vartype streams: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str - """ - - _validation = { - "streams": {"required": True}, - } - - _attribute_map = { - "streams": {"key": "streams", "type": "[str]"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, streams: List[str], name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword streams: Firewall logs streams. Required. - :paramtype streams: list[str] - :keyword name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :paramtype name: str - """ - super().__init__(**kwargs) - self.streams = streams - self.name = name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 7ee89f8ba833b..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,226 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class KnownColumnDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the column data.""" - - STRING = "string" - INT = "int" - LONG = "long" - REAL = "real" - BOOLEAN = "boolean" - DATETIME = "datetime" - DYNAMIC = "dynamic" - - -class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state. This property is READ-ONLY.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - CANCELED = "Canceled" - FAILED = "Failed" - - -class KnownDataCollectionEndpointResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource.""" - - LINUX = "Linux" - WINDOWS = "Windows" - - -class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - CANCELED = "Canceled" - FAILED = "Failed" - - -class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - CANCELED = "Canceled" - FAILED = "Failed" - - -class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the resource.""" - - LINUX = "Linux" - WINDOWS = "Windows" - - -class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownDataFlowStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownExtensionDataSourceStreams.""" - - MICROSOFT_EVENT = "Microsoft-Event" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_SYSLOG = "Microsoft-Syslog" - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - - -class KnownLocationSpecProvisioningStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The resource provisioning state in this location.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - CANCELED = "Canceled" - FAILED = "Failed" - - -class KnownLogFilesDataSourceFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The data format of the log files.""" - - TEXT = "text" - - -class KnownLogFileTextSettingsRecordStartTimestampFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """One of the supported timestamp formats.""" - - ISO8601 = "ISO 8601" - YYYY_MM_DD_HH_MM_SS = "YYYY-MM-DD HH:MM:SS" - M_D_YYYY_HH_MM_SS_AM_PM = "M/D/YYYY HH:MM:SS AM/PM" - MON_DD_YYYY_HH_MM_SS = "Mon DD, YYYY HH:MM:SS" - YY_M_MDD_HH_MM_SS = "yyMMdd HH:mm:ss" - DD_M_MYY_HH_MM_SS = "ddMMyy HH:mm:ss" - MMM_D_HH_MM_SS = "MMM d hh:mm:ss" - DD_MMM_YYYY_HH_MM_SS_ZZZ = "dd/MMM/yyyy:HH:mm:ss zzz" - YYYY_MM_DD_THH_MM_SS_K = "yyyy-MM-ddTHH:mm:ssK" - - -class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownPerfCounterDataSourceStreams.""" - - MICROSOFT_PERF = "Microsoft-Perf" - MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" - - -class KnownPrometheusForwarderDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownPrometheusForwarderDataSourceStreams.""" - - MICROSOFT_PROMETHEUS_METRICS = "Microsoft-PrometheusMetrics" - - -class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The configuration to set whether network access from public internet to the endpoints are - allowed. - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - SECURED_BY_PERIMETER = "SecuredByPerimeter" - - -class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceFacilityNames.""" - - AUTH = "auth" - AUTHPRIV = "authpriv" - CRON = "cron" - DAEMON = "daemon" - KERN = "kern" - LPR = "lpr" - MAIL = "mail" - MARK = "mark" - NEWS = "news" - SYSLOG = "syslog" - USER = "user" - UUCP = "uucp" - LOCAL0 = "local0" - LOCAL1 = "local1" - LOCAL2 = "local2" - LOCAL3 = "local3" - LOCAL4 = "local4" - LOCAL5 = "local5" - LOCAL6 = "local6" - LOCAL7 = "local7" - ASTERISK = "*" - - -class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceLogLevels.""" - - DEBUG = "Debug" - INFO = "Info" - NOTICE = "Notice" - WARNING = "Warning" - ERROR = "Error" - CRITICAL = "Critical" - ALERT = "Alert" - EMERGENCY = "Emergency" - ASTERISK = "*" - - -class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownSyslogDataSourceStreams.""" - - MICROSOFT_SYSLOG = "Microsoft-Syslog" - - -class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KnownWindowsEventLogDataSourceStreams.""" - - MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" - MICROSOFT_EVENT = "Microsoft-Event" - - -class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity (where both SystemAssigned and UserAssigned types are - allowed). - """ - - NONE = "None" - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py deleted file mode 100644 index 134b182d222e9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations -from ._data_collection_endpoints_operations import DataCollectionEndpointsOperations -from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations -from ._data_collection_rules_operations import DataCollectionRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", - "DataCollectionEndpointsOperations", - "DataCollectionRuleAssociationsOperations", - "DataCollectionRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py deleted file mode 100644 index f9f6419012809..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,2058 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_notifications_at_resource_group_level_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_request(notification_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_at_resource_group_level_request( # pylint: disable=name-too-long - resource_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long - resource_group_name: str, action_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - def _post_test_notifications_initial( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_post_test_notifications_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._post_test_notifications_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _post_test_notifications_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - @overload - def begin_post_test_notifications( - self, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_post_test_notifications( - self, notification_request: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_post_test_notifications( - self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._post_test_notifications_initial( - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_post_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" - } - - def _create_notifications_at_resource_group_level_initial( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_resource_group_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_resource_group_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - @overload - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_notifications_at_resource_group_level_initial( - resource_group_name=resource_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" - } - - def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_action_group_resource_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @overload - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2022_06_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_notifications_at_action_group_resource_level_initial( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @distributed_trace - def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_request( - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace - def get_test_notifications_at_resource_group_level( # pylint: disable=name-too-long - self, resource_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_resource_group_level_request( - resource_group_name=resource_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_resource_group_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_resource_group_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" - } - - @distributed_trace - def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2022_06_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2022_06_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_endpoints_operations.py deleted file mode 100644 index 8eeb833bdda92..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_endpoints_operations.py +++ /dev/null @@ -1,884 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.MonitorManagementClient`'s - :attr:`data_collection_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified resource group. - - Lists all data collection endpoints in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionEndpointResource"]: - """Lists all data collection endpoints in the specified subscription. - - Lists all data collection endpoints in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" - } - - @distributed_trace - def get( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Returns the specified data collection endpoint. - - Returns the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.DataCollectionEndpointResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.DataCollectionEndpointResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Creates or updates a data collection endpoint. - - Creates or updates a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionEndpointResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @overload - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - data_collection_endpoint_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionEndpointResource: - """Updates part of a data collection endpoint. - - Updates part of a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionEndpointResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionEndpointResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection endpoint. - - Deletes a data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_rule_associations_operations.py deleted file mode 100644 index 1a5da1e93321d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_rule_associations_operations.py +++ /dev/null @@ -1,801 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_rule_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_data_collection_endpoint_request( # pylint: disable=name-too-long - resource_group_name: str, data_collection_endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionEndpointName": _SERIALIZER.url( - "data_collection_endpoint_name", data_collection_endpoint_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), - "associationName": _SERIALIZER.url("association_name", association_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRuleAssociationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.MonitorManagementClient`'s - :attr:`data_collection_rule_associations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource( - self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified resource. - - Lists associations for the specified resource. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_request( - resource_uri=resource_uri, - api_version=api_version, - template_url=self.list_by_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} - - @distributed_trace - def list_by_rule( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection rule. - - Lists associations for the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_rule_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_rule.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_rule.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" - } - - @distributed_trace - def list_by_data_collection_endpoint( - self, resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResource"]: - """Lists associations for the specified data collection endpoint. - - Lists associations for the specified data collection endpoint. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_endpoint_name: The name of the data collection endpoint. The name is - case insensitive. Required. - :type data_collection_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResource or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_data_collection_endpoint_request( - resource_group_name=resource_group_name, - data_collection_endpoint_name=data_collection_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_data_collection_endpoint.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_data_collection_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations" - } - - @distributed_trace - def get( - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Returns the specified association. - - Returns the specified association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_uri: str, - association_name: str, - body: Optional[Union[_models.DataCollectionRuleAssociationProxyOnlyResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: - """Creates or updates an association. - - Creates or updates an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a - IO type. Default value is None. - :type body: - ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleAssociationProxyOnlyResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleAssociationProxyOnlyResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleAssociationProxyOnlyResource") - else: - _json = None - - request = build_create_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, association_name: str, **kwargs: Any - ) -> None: - """Deletes an association. - - Deletes an association. - - :param resource_uri: The identifier of the resource. Required. - :type resource_uri: str - :param association_name: The name of the association. The name is case insensitive. Required. - :type association_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_uri=resource_uri, - association_name=association_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_rules_operations.py deleted file mode 100644 index 178b4924c8f03..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_data_collection_rules_operations.py +++ /dev/null @@ -1,876 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, data_collection_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataCollectionRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_06_01.MonitorManagementClient`'s - :attr:`data_collection_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified resource group. - - Lists all data collection rules in the specified resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: - """Lists all data collection rules in the specified subscription. - - Lists all data collection rules in the specified subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" - } - - @distributed_trace - def get( - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Returns the specified data collection rule. - - Returns the specified data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.DataCollectionRuleResource] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.DataCollectionRuleResource, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Creates or updates a data collection rule. - - Creates or updates a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default - value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "DataCollectionRuleResource") - else: - _json = None - - request = build_create_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[_models.ResourceForUpdate] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[IO] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Default value is None. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - data_collection_rule_name: str, - body: Optional[Union[_models.ResourceForUpdate, IO]] = None, - **kwargs: Any - ) -> _models.DataCollectionRuleResource: - """Updates part of a data collection rule. - - Updates part of a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is - None. - :type body: ~azure.mgmt.monitor.v2022_06_01.models.ResourceForUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCollectionRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_06_01.models.DataCollectionRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "ResourceForUpdate") - else: - _json = None - - request = build_update_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a data collection rule. - - Deletes a data collection rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param data_collection_rule_name: The name of the data collection rule. The name is case - insensitive. Required. - :type data_collection_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - data_collection_rule_name=data_collection_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_configuration.py deleted file mode 100644 index d1bf2062b24ca..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_metadata.json deleted file mode 100644 index c6ef20d862a85..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-08-01-preview", - "total_api_version_list": ["2022-08-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "scheduled_query_rules": "ScheduledQueryRulesOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_monitor_management_client.py deleted file mode 100644 index 8d9eabf0b3eec..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: - azure.mgmt.monitor.v2022_08_01_preview.operations.ScheduledQueryRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_configuration.py deleted file mode 100644 index 3a679591e3238..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 927cae76b99e2..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: - azure.mgmt.monitor.v2022_08_01_preview.aio.operations.ScheduledQueryRulesOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/__init__.py deleted file mode 100644 index e010c281d4fc5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ScheduledQueryRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_scheduled_query_rules_operations.py deleted file mode 100644 index 3118e7bc5af8a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_scheduled_query_rules_operations.py +++ /dev/null @@ -1,654 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._scheduled_query_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ScheduledQueryRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_08_01_preview.aio.MonitorManagementClient`'s - :attr:`scheduled_query_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: - """Retrieve a scheduled query rule definitions in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: - """Retrieve scheduled query rule definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: - """Retrieve an scheduled query rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResource, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - ScheduledQueryRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: - ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a - ScheduledQueryRuleResourcePatch type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/__init__.py deleted file mode 100644 index 2fbbffcd54694..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/__init__.py +++ /dev/null @@ -1,63 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import Actions -from ._models_py3 import Condition -from ._models_py3 import ConditionFailingPeriods -from ._models_py3 import Dimension -from ._models_py3 import ErrorContract -from ._models_py3 import ErrorResponseAdditionalInfo -from ._models_py3 import ErrorResponseDetails -from ._models_py3 import Identity -from ._models_py3 import RuleResolveConfiguration -from ._models_py3 import ScheduledQueryRuleCriteria -from ._models_py3 import ScheduledQueryRuleResource -from ._models_py3 import ScheduledQueryRuleResourceCollection -from ._models_py3 import ScheduledQueryRuleResourcePatch -from ._models_py3 import SystemData -from ._models_py3 import UserIdentityProperties - -from ._monitor_management_client_enums import AlertSeverity -from ._monitor_management_client_enums import ConditionOperator -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import DimensionOperator -from ._monitor_management_client_enums import IdentityType -from ._monitor_management_client_enums import Kind -from ._monitor_management_client_enums import PublicNetworkAccess -from ._monitor_management_client_enums import TimeAggregation -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Actions", - "Condition", - "ConditionFailingPeriods", - "Dimension", - "ErrorContract", - "ErrorResponseAdditionalInfo", - "ErrorResponseDetails", - "Identity", - "RuleResolveConfiguration", - "ScheduledQueryRuleCriteria", - "ScheduledQueryRuleResource", - "ScheduledQueryRuleResourceCollection", - "ScheduledQueryRuleResourcePatch", - "SystemData", - "UserIdentityProperties", - "AlertSeverity", - "ConditionOperator", - "CreatedByType", - "DimensionOperator", - "IdentityType", - "Kind", - "PublicNetworkAccess", - "TimeAggregation", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_models_py3.py deleted file mode 100644 index 8d9bb334bf546..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1047 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Actions(_serialization.Model): - """Actions to invoke when the alert fires. - - :ivar action_groups: Action Group resource Ids to invoke when the alert fires. - :vartype action_groups: list[str] - :ivar custom_properties: The properties of an alert payload. - :vartype custom_properties: dict[str, str] - """ - - _attribute_map = { - "action_groups": {"key": "actionGroups", "type": "[str]"}, - "custom_properties": {"key": "customProperties", "type": "{str}"}, - } - - def __init__( - self, - *, - action_groups: Optional[List[str]] = None, - custom_properties: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword action_groups: Action Group resource Ids to invoke when the alert fires. - :paramtype action_groups: list[str] - :keyword custom_properties: The properties of an alert payload. - :paramtype custom_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.action_groups = action_groups - self.custom_properties = custom_properties - - -class Condition(_serialization.Model): - """A condition of the scheduled query rule. - - :ivar query: Log query alert. - :vartype query: str - :ivar time_aggregation: Aggregation type. Relevant and required only for rules of the kind - LogAlert. Known values are: "Count", "Average", "Minimum", "Maximum", and "Total". - :vartype time_aggregation: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.TimeAggregation - :ivar metric_measure_column: The column containing the metric measure number. Relevant only for - rules of the kind LogAlert. - :vartype metric_measure_column: str - :ivar resource_id_column: The column containing the resource id. The content of the column must - be a uri formatted as resource id. Relevant only for rules of the kind LogAlert. - :vartype resource_id_column: str - :ivar dimensions: List of Dimensions conditions. - :vartype dimensions: list[~azure.mgmt.monitor.v2022_08_01_preview.models.Dimension] - :ivar operator: The criteria operator. Relevant and required only for rules of the kind - LogAlert. Known values are: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", and - "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.ConditionOperator - :ivar threshold: the criteria threshold value that activates the alert. Relevant and required - only for rules of the kind LogAlert. - :vartype threshold: float - :ivar failing_periods: The minimum number of violations required within the selected lookback - time window required to raise an alert. Relevant only for rules of the kind LogAlert. - :vartype failing_periods: - ~azure.mgmt.monitor.v2022_08_01_preview.models.ConditionFailingPeriods - :ivar metric_name: The name of the metric to be sent. Relevant and required only for rules of - the kind LogToMetric. - :vartype metric_name: str - """ - - _attribute_map = { - "query": {"key": "query", "type": "str"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "metric_measure_column": {"key": "metricMeasureColumn", "type": "str"}, - "resource_id_column": {"key": "resourceIdColumn", "type": "str"}, - "dimensions": {"key": "dimensions", "type": "[Dimension]"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "failing_periods": {"key": "failingPeriods", "type": "ConditionFailingPeriods"}, - "metric_name": {"key": "metricName", "type": "str"}, - } - - def __init__( - self, - *, - query: Optional[str] = None, - time_aggregation: Optional[Union[str, "_models.TimeAggregation"]] = None, - metric_measure_column: Optional[str] = None, - resource_id_column: Optional[str] = None, - dimensions: Optional[List["_models.Dimension"]] = None, - operator: Optional[Union[str, "_models.ConditionOperator"]] = None, - threshold: Optional[float] = None, - failing_periods: Optional["_models.ConditionFailingPeriods"] = None, - metric_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword query: Log query alert. - :paramtype query: str - :keyword time_aggregation: Aggregation type. Relevant and required only for rules of the kind - LogAlert. Known values are: "Count", "Average", "Minimum", "Maximum", and "Total". - :paramtype time_aggregation: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.TimeAggregation - :keyword metric_measure_column: The column containing the metric measure number. Relevant only - for rules of the kind LogAlert. - :paramtype metric_measure_column: str - :keyword resource_id_column: The column containing the resource id. The content of the column - must be a uri formatted as resource id. Relevant only for rules of the kind LogAlert. - :paramtype resource_id_column: str - :keyword dimensions: List of Dimensions conditions. - :paramtype dimensions: list[~azure.mgmt.monitor.v2022_08_01_preview.models.Dimension] - :keyword operator: The criteria operator. Relevant and required only for rules of the kind - LogAlert. Known values are: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", and - "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.ConditionOperator - :keyword threshold: the criteria threshold value that activates the alert. Relevant and - required only for rules of the kind LogAlert. - :paramtype threshold: float - :keyword failing_periods: The minimum number of violations required within the selected - lookback time window required to raise an alert. Relevant only for rules of the kind LogAlert. - :paramtype failing_periods: - ~azure.mgmt.monitor.v2022_08_01_preview.models.ConditionFailingPeriods - :keyword metric_name: The name of the metric to be sent. Relevant and required only for rules - of the kind LogToMetric. - :paramtype metric_name: str - """ - super().__init__(**kwargs) - self.query = query - self.time_aggregation = time_aggregation - self.metric_measure_column = metric_measure_column - self.resource_id_column = resource_id_column - self.dimensions = dimensions - self.operator = operator - self.threshold = threshold - self.failing_periods = failing_periods - self.metric_name = metric_name - - -class ConditionFailingPeriods(_serialization.Model): - """The minimum number of violations required within the selected lookback time window required to - raise an alert. Relevant only for rules of the kind LogAlert. - - :ivar number_of_evaluation_periods: 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. Default value is 1. - :vartype number_of_evaluation_periods: int - :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be - smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :vartype min_failing_periods_to_alert: int - """ - - _attribute_map = { - "number_of_evaluation_periods": {"key": "numberOfEvaluationPeriods", "type": "int"}, - "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "int"}, - } - - def __init__( - self, *, number_of_evaluation_periods: int = 1, min_failing_periods_to_alert: int = 1, **kwargs: Any - ) -> None: - """ - :keyword number_of_evaluation_periods: 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. Default value is 1. - :paramtype number_of_evaluation_periods: int - :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be - smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :paramtype min_failing_periods_to_alert: int - """ - super().__init__(**kwargs) - self.number_of_evaluation_periods = number_of_evaluation_periods - self.min_failing_periods_to_alert = min_failing_periods_to_alert - - -class Dimension(_serialization.Model): - """Dimension splitting and filtering definition. - - All required parameters must be populated in order to send to Azure. - - :ivar name: Name of the dimension. Required. - :vartype name: str - :ivar operator: Operator for dimension values. Required. Known values are: "Include" and - "Exclude". - :vartype operator: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.DimensionOperator - :ivar values: List of dimension values. Required. - :vartype values: list[str] - """ - - _validation = { - "name": {"required": True}, - "operator": {"required": True}, - "values": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - } - - def __init__( - self, *, name: str, operator: Union[str, "_models.DimensionOperator"], values: List[str], **kwargs: Any - ) -> None: - """ - :keyword name: Name of the dimension. Required. - :paramtype name: str - :keyword operator: Operator for dimension values. Required. Known values are: "Include" and - "Exclude". - :paramtype operator: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.DimensionOperator - :keyword values: List of dimension values. Required. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.name = name - self.operator = operator - self.values = values - - -class ErrorContract(_serialization.Model): - """Describes the format of Error response. - - :ivar error: The error details. - :vartype error: ~azure.mgmt.monitor.v2022_08_01_preview.models.ErrorResponseDetails - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponseDetails"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponseDetails"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error details. - :paramtype error: ~azure.mgmt.monitor.v2022_08_01_preview.models.ErrorResponseDetails - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponseAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorResponseDetails(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.monitor.v2022_08_01_preview.models.ErrorResponseDetails] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.monitor.v2022_08_01_preview.models.ErrorResponseAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorResponseDetails]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorResponseAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Identity(_serialization.Model): - """Identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :ivar type: Type of managed service identity. Required. Known values are: "SystemAssigned", - "UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.IdentityType - :ivar user_assigned_identities: The list of user identities associated with the resource. The - user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_08_01_preview.models.UserIdentityProperties] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.IdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity. Required. Known values are: "SystemAssigned", - "UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.IdentityType - :keyword user_assigned_identities: The list of user identities associated with the resource. - The user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.monitor.v2022_08_01_preview.models.UserIdentityProperties] - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = type - self.user_assigned_identities = user_assigned_identities - - -class RuleResolveConfiguration(_serialization.Model): - """TBD. Relevant only for rules of the kind LogAlert. - - :ivar auto_resolved: The flag that indicates whether or not to auto resolve a fired alert. - :vartype auto_resolved: bool - :ivar time_to_resolve: The duration a rule must evaluate as healthy before the fired alert is - automatically resolved represented in ISO 8601 duration format. - :vartype time_to_resolve: ~datetime.timedelta - """ - - _attribute_map = { - "auto_resolved": {"key": "autoResolved", "type": "bool"}, - "time_to_resolve": {"key": "timeToResolve", "type": "duration"}, - } - - def __init__( - self, - *, - auto_resolved: Optional[bool] = None, - time_to_resolve: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword auto_resolved: The flag that indicates whether or not to auto resolve a fired alert. - :paramtype auto_resolved: bool - :keyword time_to_resolve: The duration a rule must evaluate as healthy before the fired alert - is automatically resolved represented in ISO 8601 duration format. - :paramtype time_to_resolve: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.auto_resolved = auto_resolved - self.time_to_resolve = time_to_resolve - - -class ScheduledQueryRuleCriteria(_serialization.Model): - """The rule criteria that defines the conditions of the scheduled query rule. - - :ivar all_of: A list of conditions to evaluate against the specified scopes. - :vartype all_of: list[~azure.mgmt.monitor.v2022_08_01_preview.models.Condition] - """ - - _attribute_map = { - "all_of": {"key": "allOf", "type": "[Condition]"}, - } - - def __init__(self, *, all_of: Optional[List["_models.Condition"]] = None, **kwargs: Any) -> None: - """ - :keyword all_of: A list of conditions to evaluate against the specified scopes. - :paramtype all_of: list[~azure.mgmt.monitor.v2022_08_01_preview.models.Condition] - """ - super().__init__(**kwargs) - self.all_of = all_of - - -class ScheduledQueryRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The scheduled query rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.monitor.v2022_08_01_preview.models.Identity - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar kind: Indicates the type of scheduled query rule. The default is LogAlert. Known values - are: "LogAlert" and "LogToMetric". - :vartype kind: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.Kind - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - :ivar system_data: SystemData of ScheduledQueryRule. - :vartype system_data: ~azure.mgmt.monitor.v2022_08_01_preview.models.SystemData - :ivar created_with_api_version: The api-version used when creating this alert rule. - :vartype created_with_api_version: str - :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. - :vartype is_legacy_log_analytics_rule: bool - :ivar description: The description of the scheduled query rule. - :vartype description: str - :ivar display_name: The display name of the alert rule. - :vartype display_name: str - :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, - 3, and 4. - :vartype severity: int or ~azure.mgmt.monitor.v2022_08_01_preview.models.AlertSeverity - :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :vartype enabled: bool - :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.PublicNetworkAccess - :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. - :vartype scopes: list[str] - :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO - 8601 duration format. Relevant and required only for rules of the kind LogAlert. - :vartype evaluation_frequency: ~datetime.timedelta - :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). Relevant and required only for rules of the kind LogAlert. - :vartype window_size: ~datetime.timedelta - :ivar override_query_time_range: If specified then overrides the query time range (default is - WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. - :vartype override_query_time_range: ~datetime.timedelta - :ivar target_resource_types: List of resource type of the target resource(s) on which the alert - is created/updated. For example if the scope is a resource group and targetResourceTypes is - Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. Relevant only for rules of the - kind LogAlert. - :vartype target_resource_types: list[str] - :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. - :vartype criteria: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleCriteria - :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration - format) after the alert is fired. Relevant only for rules of the kind LogAlert. - :vartype mute_actions_duration: ~datetime.timedelta - :ivar actions: Actions to invoke when the alert fires. - :vartype actions: ~azure.mgmt.monitor.v2022_08_01_preview.models.Actions - :ivar is_workspace_alerts_storage_configured: The flag which indicates whether this scheduled - query rule has been configured to be stored in the customer's storage. The default is false. - :vartype is_workspace_alerts_storage_configured: bool - :ivar check_workspace_alerts_storage_configured: The flag which indicates whether this - scheduled query rule should be stored in the customer's storage. The default is false. Relevant - only for rules of the kind LogAlert. - :vartype check_workspace_alerts_storage_configured: bool - :ivar skip_query_validation: The flag which indicates whether the provided query should be - validated or not. The default is false. Relevant only for rules of the kind LogAlert. - :vartype skip_query_validation: bool - :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved - or not. The default is true. Relevant only for rules of the kind LogAlert. - :vartype auto_mitigate: bool - :ivar rule_resolve_configuration: Defines the configuration for resolving fired alerts. - Relevant only for rules of the kind LogAlert. - :vartype rule_resolve_configuration: - ~azure.mgmt.monitor.v2022_08_01_preview.models.RuleResolveConfiguration - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "etag": {"readonly": True}, - "system_data": {"readonly": True}, - "created_with_api_version": {"readonly": True}, - "is_legacy_log_analytics_rule": {"readonly": True}, - "is_workspace_alerts_storage_configured": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "identity": {"key": "identity", "type": "Identity"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, - "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "severity": {"key": "properties.severity", "type": "int"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, - "window_size": {"key": "properties.windowSize", "type": "duration"}, - "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, - "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, - "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, - "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, - "actions": {"key": "properties.actions", "type": "Actions"}, - "is_workspace_alerts_storage_configured": { - "key": "properties.isWorkspaceAlertsStorageConfigured", - "type": "bool", - }, - "check_workspace_alerts_storage_configured": { - "key": "properties.checkWorkspaceAlertsStorageConfigured", - "type": "bool", - }, - "skip_query_validation": {"key": "properties.skipQueryValidation", "type": "bool"}, - "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, - "rule_resolve_configuration": { - "key": "properties.ruleResolveConfiguration", - "type": "RuleResolveConfiguration", - }, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - identity: Optional["_models.Identity"] = None, - tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "_models.Kind"]] = None, - description: Optional[str] = None, - display_name: Optional[str] = None, - severity: Optional[Union[int, "_models.AlertSeverity"]] = None, - enabled: Optional[bool] = None, - public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", - scopes: Optional[List[str]] = None, - evaluation_frequency: Optional[datetime.timedelta] = None, - window_size: Optional[datetime.timedelta] = None, - override_query_time_range: Optional[datetime.timedelta] = None, - target_resource_types: Optional[List[str]] = None, - criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, - mute_actions_duration: Optional[datetime.timedelta] = None, - actions: Optional["_models.Actions"] = None, - check_workspace_alerts_storage_configured: Optional[bool] = None, - skip_query_validation: Optional[bool] = None, - auto_mitigate: Optional[bool] = None, - rule_resolve_configuration: Optional["_models.RuleResolveConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.monitor.v2022_08_01_preview.models.Identity - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. - :paramtype location: str - :keyword kind: Indicates the type of scheduled query rule. The default is LogAlert. Known - values are: "LogAlert" and "LogToMetric". - :paramtype kind: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.Kind - :keyword description: The description of the scheduled query rule. - :paramtype description: str - :keyword display_name: The display name of the alert rule. - :paramtype display_name: str - :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, - 3, and 4. - :paramtype severity: int or ~azure.mgmt.monitor.v2022_08_01_preview.models.AlertSeverity - :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :paramtype enabled: bool - :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.PublicNetworkAccess - :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. - :paramtype scopes: list[str] - :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in - ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert. - :paramtype evaluation_frequency: ~datetime.timedelta - :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). Relevant and required only for rules of the kind LogAlert. - :paramtype window_size: ~datetime.timedelta - :keyword override_query_time_range: If specified then overrides the query time range (default - is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. - :paramtype override_query_time_range: ~datetime.timedelta - :keyword target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. Relevant only for rules of the - kind LogAlert. - :paramtype target_resource_types: list[str] - :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. - :paramtype criteria: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleCriteria - :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 - duration format) after the alert is fired. Relevant only for rules of the kind LogAlert. - :paramtype mute_actions_duration: ~datetime.timedelta - :keyword actions: Actions to invoke when the alert fires. - :paramtype actions: ~azure.mgmt.monitor.v2022_08_01_preview.models.Actions - :keyword check_workspace_alerts_storage_configured: The flag which indicates whether this - scheduled query rule should be stored in the customer's storage. The default is false. Relevant - only for rules of the kind LogAlert. - :paramtype check_workspace_alerts_storage_configured: bool - :keyword skip_query_validation: The flag which indicates whether the provided query should be - validated or not. The default is false. Relevant only for rules of the kind LogAlert. - :paramtype skip_query_validation: bool - :keyword auto_mitigate: The flag that indicates whether the alert should be automatically - resolved or not. The default is true. Relevant only for rules of the kind LogAlert. - :paramtype auto_mitigate: bool - :keyword rule_resolve_configuration: Defines the configuration for resolving fired alerts. - Relevant only for rules of the kind LogAlert. - :paramtype rule_resolve_configuration: - ~azure.mgmt.monitor.v2022_08_01_preview.models.RuleResolveConfiguration - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.identity = identity - self.tags = tags - self.location = location - self.kind = kind - self.etag = None - self.system_data = None - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = description - self.display_name = display_name - self.severity = severity - self.enabled = enabled - self.public_network_access = public_network_access - self.scopes = scopes - self.evaluation_frequency = evaluation_frequency - self.window_size = window_size - self.override_query_time_range = override_query_time_range - self.target_resource_types = target_resource_types - self.criteria = criteria - self.mute_actions_duration = mute_actions_duration - self.actions = actions - self.is_workspace_alerts_storage_configured = None - self.check_workspace_alerts_storage_configured = check_workspace_alerts_storage_configured - self.skip_query_validation = skip_query_validation - self.auto_mitigate = auto_mitigate - self.rule_resolve_configuration = rule_resolve_configuration - - -class ScheduledQueryRuleResourceCollection(_serialization.Model): - """Represents a collection of scheduled query rule resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The values for the scheduled query rule resources. - :vartype value: list[~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ScheduledQueryRuleResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The values for the scheduled query rule resources. - :paramtype value: - list[~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ScheduledQueryRuleResourcePatch(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The scheduled query rule resource for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.monitor.v2022_08_01_preview.models.Identity - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar created_with_api_version: The api-version used when creating this alert rule. - :vartype created_with_api_version: str - :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. - :vartype is_legacy_log_analytics_rule: bool - :ivar description: The description of the scheduled query rule. - :vartype description: str - :ivar display_name: The display name of the alert rule. - :vartype display_name: str - :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, - 3, and 4. - :vartype severity: int or ~azure.mgmt.monitor.v2022_08_01_preview.models.AlertSeverity - :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :vartype enabled: bool - :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :vartype public_network_access: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.PublicNetworkAccess - :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. - :vartype scopes: list[str] - :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO - 8601 duration format. Relevant and required only for rules of the kind LogAlert. - :vartype evaluation_frequency: ~datetime.timedelta - :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). Relevant and required only for rules of the kind LogAlert. - :vartype window_size: ~datetime.timedelta - :ivar override_query_time_range: If specified then overrides the query time range (default is - WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. - :vartype override_query_time_range: ~datetime.timedelta - :ivar target_resource_types: List of resource type of the target resource(s) on which the alert - is created/updated. For example if the scope is a resource group and targetResourceTypes is - Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. Relevant only for rules of the - kind LogAlert. - :vartype target_resource_types: list[str] - :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. - :vartype criteria: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleCriteria - :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration - format) after the alert is fired. Relevant only for rules of the kind LogAlert. - :vartype mute_actions_duration: ~datetime.timedelta - :ivar actions: Actions to invoke when the alert fires. - :vartype actions: ~azure.mgmt.monitor.v2022_08_01_preview.models.Actions - :ivar is_workspace_alerts_storage_configured: The flag which indicates whether this scheduled - query rule has been configured to be stored in the customer's storage. The default is false. - :vartype is_workspace_alerts_storage_configured: bool - :ivar check_workspace_alerts_storage_configured: The flag which indicates whether this - scheduled query rule should be stored in the customer's storage. The default is false. Relevant - only for rules of the kind LogAlert. - :vartype check_workspace_alerts_storage_configured: bool - :ivar skip_query_validation: The flag which indicates whether the provided query should be - validated or not. The default is false. Relevant only for rules of the kind LogAlert. - :vartype skip_query_validation: bool - :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved - or not. The default is true. Relevant only for rules of the kind LogAlert. - :vartype auto_mitigate: bool - :ivar rule_resolve_configuration: Defines the configuration for resolving fired alerts. - Relevant only for rules of the kind LogAlert. - :vartype rule_resolve_configuration: - ~azure.mgmt.monitor.v2022_08_01_preview.models.RuleResolveConfiguration - """ - - _validation = { - "created_with_api_version": {"readonly": True}, - "is_legacy_log_analytics_rule": {"readonly": True}, - "is_workspace_alerts_storage_configured": {"readonly": True}, - } - - _attribute_map = { - "identity": {"key": "identity", "type": "Identity"}, - "tags": {"key": "tags", "type": "{str}"}, - "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, - "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "severity": {"key": "properties.severity", "type": "int"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "scopes": {"key": "properties.scopes", "type": "[str]"}, - "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, - "window_size": {"key": "properties.windowSize", "type": "duration"}, - "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, - "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, - "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, - "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, - "actions": {"key": "properties.actions", "type": "Actions"}, - "is_workspace_alerts_storage_configured": { - "key": "properties.isWorkspaceAlertsStorageConfigured", - "type": "bool", - }, - "check_workspace_alerts_storage_configured": { - "key": "properties.checkWorkspaceAlertsStorageConfigured", - "type": "bool", - }, - "skip_query_validation": {"key": "properties.skipQueryValidation", "type": "bool"}, - "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, - "rule_resolve_configuration": { - "key": "properties.ruleResolveConfiguration", - "type": "RuleResolveConfiguration", - }, - } - - def __init__( - self, - *, - identity: Optional["_models.Identity"] = None, - tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - display_name: Optional[str] = None, - severity: Optional[Union[int, "_models.AlertSeverity"]] = None, - enabled: Optional[bool] = None, - public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", - scopes: Optional[List[str]] = None, - evaluation_frequency: Optional[datetime.timedelta] = None, - window_size: Optional[datetime.timedelta] = None, - override_query_time_range: Optional[datetime.timedelta] = None, - target_resource_types: Optional[List[str]] = None, - criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, - mute_actions_duration: Optional[datetime.timedelta] = None, - actions: Optional["_models.Actions"] = None, - check_workspace_alerts_storage_configured: Optional[bool] = None, - skip_query_validation: Optional[bool] = None, - auto_mitigate: Optional[bool] = None, - rule_resolve_configuration: Optional["_models.RuleResolveConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: The identity of the resource. - :paramtype identity: ~azure.mgmt.monitor.v2022_08_01_preview.models.Identity - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword description: The description of the scheduled query rule. - :paramtype description: str - :keyword display_name: The display name of the alert rule. - :paramtype display_name: str - :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is - severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, - 3, and 4. - :paramtype severity: int or ~azure.mgmt.monitor.v2022_08_01_preview.models.AlertSeverity - :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value - should be true or false. - :paramtype enabled: bool - :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :paramtype public_network_access: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.PublicNetworkAccess - :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. - :paramtype scopes: list[str] - :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in - ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert. - :paramtype evaluation_frequency: ~datetime.timedelta - :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query - will be executed (bin size). Relevant and required only for rules of the kind LogAlert. - :paramtype window_size: ~datetime.timedelta - :keyword override_query_time_range: If specified then overrides the query time range (default - is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. - :paramtype override_query_time_range: ~datetime.timedelta - :keyword target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual - machine in the resource group which meet the alert criteria. Relevant only for rules of the - kind LogAlert. - :paramtype target_resource_types: list[str] - :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. - :paramtype criteria: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleCriteria - :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 - duration format) after the alert is fired. Relevant only for rules of the kind LogAlert. - :paramtype mute_actions_duration: ~datetime.timedelta - :keyword actions: Actions to invoke when the alert fires. - :paramtype actions: ~azure.mgmt.monitor.v2022_08_01_preview.models.Actions - :keyword check_workspace_alerts_storage_configured: The flag which indicates whether this - scheduled query rule should be stored in the customer's storage. The default is false. Relevant - only for rules of the kind LogAlert. - :paramtype check_workspace_alerts_storage_configured: bool - :keyword skip_query_validation: The flag which indicates whether the provided query should be - validated or not. The default is false. Relevant only for rules of the kind LogAlert. - :paramtype skip_query_validation: bool - :keyword auto_mitigate: The flag that indicates whether the alert should be automatically - resolved or not. The default is true. Relevant only for rules of the kind LogAlert. - :paramtype auto_mitigate: bool - :keyword rule_resolve_configuration: Defines the configuration for resolving fired alerts. - Relevant only for rules of the kind LogAlert. - :paramtype rule_resolve_configuration: - ~azure.mgmt.monitor.v2022_08_01_preview.models.RuleResolveConfiguration - """ - super().__init__(**kwargs) - self.identity = identity - self.tags = tags - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = description - self.display_name = display_name - self.severity = severity - self.enabled = enabled - self.public_network_access = public_network_access - self.scopes = scopes - self.evaluation_frequency = evaluation_frequency - self.window_size = window_size - self.override_query_time_range = override_query_time_range - self.target_resource_types = target_resource_types - self.criteria = criteria - self.mute_actions_duration = mute_actions_duration - self.actions = actions - self.is_workspace_alerts_storage_configured = None - self.check_workspace_alerts_storage_configured = check_workspace_alerts_storage_configured - self.skip_query_validation = skip_query_validation - self.auto_mitigate = auto_mitigate - self.rule_resolve_configuration = rule_resolve_configuration - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_08_01_preview.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.monitor.v2022_08_01_preview.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class UserIdentityProperties(_serialization.Model): - """User assigned identity properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 087b33ff7efe4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AlertSeverity(int, Enum, metaclass=CaseInsensitiveEnumMeta): - """Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and - required only for rules of the kind LogAlert. - """ - - ZERO = 0 - ONE = 1 - TWO = 2 - THREE = 3 - FOUR = 4 - - -class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The criteria operator. Relevant and required only for rules of the kind LogAlert.""" - - EQUALS = "Equals" - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class DimensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operator for dimension values.""" - - INCLUDE = "Include" - EXCLUDE = "Exclude" - - -class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity.""" - - SYSTEM_ASSIGNED = "SystemAssigned" - USER_ASSIGNED = "UserAssigned" - NONE = "None" - - -class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of scheduled query rule. The default is LogAlert.""" - - LOG_ALERT = "LogAlert" - LOG_TO_METRIC = "LogToMetric" - - -class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled.""" - - ENABLED = "Enabled" - DISABLED = "Disabled" - SECURED_BY_PERIMETER = "SecuredByPerimeter" - - -class TimeAggregation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Aggregation type. Relevant and required only for rules of the kind LogAlert.""" - - COUNT = "Count" - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/__init__.py deleted file mode 100644 index e010c281d4fc5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ScheduledQueryRulesOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_scheduled_query_rules_operations.py deleted file mode 100644 index 0cd8c1d54760c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_scheduled_query_rules_operations.py +++ /dev/null @@ -1,837 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ScheduledQueryRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_08_01_preview.MonitorManagementClient`'s - :attr:`scheduled_query_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ScheduledQueryRuleResource"]: - """Retrieve a scheduled query rule definitions in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ScheduledQueryRuleResource"]: - """Retrieve scheduled query rule definitions in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScheduledQueryRuleResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" - } - - @distributed_trace - def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: - """Retrieve an scheduled query rule definition. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResource, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Creates or updates a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a - ScheduledQueryRuleResource type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: _models.ScheduledQueryRuleResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: - ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - rule_name: str, - parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], - **kwargs: Any - ) -> _models.ScheduledQueryRuleResource: - """Update a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a - ScheduledQueryRuleResourcePatch type or a IO type. Required. - :type parameters: - ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScheduledQueryRuleResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_08_01_preview.models.ScheduledQueryRuleResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, rule_name: str, **kwargs: Any - ) -> None: - """Deletes a scheduled query rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param rule_name: The name of the rule. Required. - :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_configuration.py deleted file mode 100644 index a47c12c4834c1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_metadata.json deleted file mode 100644 index 13f751ef148e7..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2022-10-01", - "total_api_version_list": ["2022-10-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "autoscale_settings": "AutoscaleSettingsOperations", - "predictive_metric": "PredictiveMetricOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_monitor_management_client.py deleted file mode 100644 index 1bb05affeb7ed..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import AutoscaleSettingsOperations, PredictiveMetricOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: - azure.mgmt.monitor.v2022_10_01.operations.AutoscaleSettingsOperations - :ivar predictive_metric: PredictiveMetricOperations operations - :vartype predictive_metric: - azure.mgmt.monitor.v2022_10_01.operations.PredictiveMetricOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.predictive_metric = PredictiveMetricOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_configuration.py deleted file mode 100644 index a0bd7f0de702f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_monitor_management_client.py deleted file mode 100644 index 5e131d74b38eb..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import AutoscaleSettingsOperations, PredictiveMetricOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: - azure.mgmt.monitor.v2022_10_01.aio.operations.AutoscaleSettingsOperations - :ivar predictive_metric: PredictiveMetricOperations operations - :vartype predictive_metric: - azure.mgmt.monitor.v2022_10_01.aio.operations.PredictiveMetricOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.predictive_metric = PredictiveMetricOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/__init__.py deleted file mode 100644 index 3d1ab289551f4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._autoscale_settings_operations import AutoscaleSettingsOperations -from ._predictive_metric_operations import PredictiveMetricOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoscaleSettingsOperations", - "PredictiveMetricOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_autoscale_settings_operations.py deleted file mode 100644 index b6db3e4214dc5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_autoscale_settings_operations.py +++ /dev/null @@ -1,658 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._autoscale_settings_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_by_subscription_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AutoscaleSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_10_01.aio.MonitorManagementClient`'s - :attr:`autoscale_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" - } - - @overload - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: _models.AutoscaleSettingResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: Union[_models.AutoscaleSettingResource, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AutoscaleSettingResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> None: - """Deletes and autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace_async - async def get( - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Gets an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @overload - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a - AutoscaleSettingResourcePatch type or a IO type. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(autoscale_setting_resource, (IO, bytes)): - _content = autoscale_setting_resource - else: - _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_predictive_metric_operations.py deleted file mode 100644 index 71a0f12ce4c58..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_predictive_metric_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._predictive_metric_operations import build_get_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PredictiveMetricOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_10_01.aio.MonitorManagementClient`'s - :attr:`predictive_metric` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - timespan: str, - interval: datetime.timedelta, - metric_namespace: str, - metric_name: str, - aggregation: str, - **kwargs: Any - ) -> _models.PredictiveResponse: - """get predictive autoscale metric future data. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Required. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Required. - :type interval: ~datetime.timedelta - :param metric_namespace: Metric namespace to query metric definitions for. Required. - :type metric_namespace: str - :param metric_name: 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'**. Required. - :type metric_name: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. - :type aggregation: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PredictiveResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.PredictiveResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - timespan=timespan, - interval=interval, - metric_namespace=metric_namespace, - metric_name=metric_name, - aggregation=aggregation, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PredictiveResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/__init__.py deleted file mode 100644 index e5589ba8fa19a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AutoscaleErrorResponse -from ._models_py3 import AutoscaleErrorResponseError -from ._models_py3 import AutoscaleNotification -from ._models_py3 import AutoscaleProfile -from ._models_py3 import AutoscaleSettingResource -from ._models_py3 import AutoscaleSettingResourceCollection -from ._models_py3 import AutoscaleSettingResourcePatch -from ._models_py3 import EmailNotification -from ._models_py3 import MetricTrigger -from ._models_py3 import PredictiveAutoscalePolicy -from ._models_py3 import PredictiveResponse -from ._models_py3 import PredictiveValue -from ._models_py3 import Recurrence -from ._models_py3 import RecurrentSchedule -from ._models_py3 import Resource -from ._models_py3 import ScaleAction -from ._models_py3 import ScaleCapacity -from ._models_py3 import ScaleRule -from ._models_py3 import ScaleRuleMetricDimension -from ._models_py3 import SystemData -from ._models_py3 import TimeWindow -from ._models_py3 import WebhookNotification - -from ._monitor_management_client_enums import ComparisonOperationType -from ._monitor_management_client_enums import CreatedByType -from ._monitor_management_client_enums import MetricStatisticType -from ._monitor_management_client_enums import PredictiveAutoscalePolicyScaleMode -from ._monitor_management_client_enums import RecurrenceFrequency -from ._monitor_management_client_enums import ScaleDirection -from ._monitor_management_client_enums import ScaleRuleMetricDimensionOperationType -from ._monitor_management_client_enums import ScaleType -from ._monitor_management_client_enums import TimeAggregationType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoscaleErrorResponse", - "AutoscaleErrorResponseError", - "AutoscaleNotification", - "AutoscaleProfile", - "AutoscaleSettingResource", - "AutoscaleSettingResourceCollection", - "AutoscaleSettingResourcePatch", - "EmailNotification", - "MetricTrigger", - "PredictiveAutoscalePolicy", - "PredictiveResponse", - "PredictiveValue", - "Recurrence", - "RecurrentSchedule", - "Resource", - "ScaleAction", - "ScaleCapacity", - "ScaleRule", - "ScaleRuleMetricDimension", - "SystemData", - "TimeWindow", - "WebhookNotification", - "ComparisonOperationType", - "CreatedByType", - "MetricStatisticType", - "PredictiveAutoscalePolicyScaleMode", - "RecurrenceFrequency", - "ScaleDirection", - "ScaleRuleMetricDimensionOperationType", - "ScaleType", - "TimeAggregationType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_models_py3.py deleted file mode 100644 index c47a2643e8f06..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_models_py3.py +++ /dev/null @@ -1,1377 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AutoscaleErrorResponse(_serialization.Model): - """Describes the format of Error response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error: The error object. - :vartype error: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleErrorResponseError - :ivar system_data: The system metadata related to the response. - :vartype system_data: ~azure.mgmt.monitor.v2022_10_01.models.SystemData - """ - - _validation = { - "system_data": {"readonly": True}, - } - - _attribute_map = { - "error": {"key": "error", "type": "AutoscaleErrorResponseError"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleErrorResponseError - """ - super().__init__(**kwargs) - self.error = error - self.system_data = None - - -class AutoscaleErrorResponseError(_serialization.Model): - """The error object. - - :ivar code: One of a server-defined set of error codes. - :vartype code: str - :ivar message: A human-readable representation of the error. - :vartype message: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar details: A human-readable representation of the error's details. - :vartype details: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "str"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - target: Optional[str] = None, - details: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: One of a server-defined set of error codes. - :paramtype code: str - :keyword message: A human-readable representation of the error. - :paramtype message: str - :keyword target: The target of the particular error. - :paramtype target: str - :keyword details: A human-readable representation of the error's details. - :paramtype details: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - self.target = target - self.details = details - - -class AutoscaleNotification(_serialization.Model): - """Autoscale notification. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar operation: the operation associated with the notification and its value must be "scale". - Required. Default value is "Scale". - :vartype operation: str - :ivar email: the email notification. - :vartype email: ~azure.mgmt.monitor.v2022_10_01.models.EmailNotification - :ivar webhooks: the collection of webhook notifications. - :vartype webhooks: list[~azure.mgmt.monitor.v2022_10_01.models.WebhookNotification] - """ - - _validation = { - "operation": {"required": True, "constant": True}, - } - - _attribute_map = { - "operation": {"key": "operation", "type": "str"}, - "email": {"key": "email", "type": "EmailNotification"}, - "webhooks": {"key": "webhooks", "type": "[WebhookNotification]"}, - } - - operation = "Scale" - - def __init__( - self, - *, - email: Optional["_models.EmailNotification"] = None, - webhooks: Optional[List["_models.WebhookNotification"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword email: the email notification. - :paramtype email: ~azure.mgmt.monitor.v2022_10_01.models.EmailNotification - :keyword webhooks: the collection of webhook notifications. - :paramtype webhooks: list[~azure.mgmt.monitor.v2022_10_01.models.WebhookNotification] - """ - super().__init__(**kwargs) - self.email = email - self.webhooks = webhooks - - -class AutoscaleProfile(_serialization.Model): - """Autoscale profile. - - All required parameters must be populated in order to send to Azure. - - :ivar name: the name of the profile. Required. - :vartype name: str - :ivar capacity: the number of instances that can be used during this profile. Required. - :vartype capacity: ~azure.mgmt.monitor.v2022_10_01.models.ScaleCapacity - :ivar rules: the collection of rules that provide the triggers and parameters for the scaling - action. A maximum of 10 rules can be specified. Required. - :vartype rules: list[~azure.mgmt.monitor.v2022_10_01.models.ScaleRule] - :ivar fixed_date: the specific date-time for the profile. This element is not used if the - Recurrence element is used. - :vartype fixed_date: ~azure.mgmt.monitor.v2022_10_01.models.TimeWindow - :ivar recurrence: the repeating times at which this profile begins. This element is not used if - the FixedDate element is used. - :vartype recurrence: ~azure.mgmt.monitor.v2022_10_01.models.Recurrence - """ - - _validation = { - "name": {"required": True}, - "capacity": {"required": True}, - "rules": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "capacity": {"key": "capacity", "type": "ScaleCapacity"}, - "rules": {"key": "rules", "type": "[ScaleRule]"}, - "fixed_date": {"key": "fixedDate", "type": "TimeWindow"}, - "recurrence": {"key": "recurrence", "type": "Recurrence"}, - } - - def __init__( - self, - *, - name: str, - capacity: "_models.ScaleCapacity", - rules: List["_models.ScaleRule"], - fixed_date: Optional["_models.TimeWindow"] = None, - recurrence: Optional["_models.Recurrence"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: the name of the profile. Required. - :paramtype name: str - :keyword capacity: the number of instances that can be used during this profile. Required. - :paramtype capacity: ~azure.mgmt.monitor.v2022_10_01.models.ScaleCapacity - :keyword rules: the collection of rules that provide the triggers and parameters for the - scaling action. A maximum of 10 rules can be specified. Required. - :paramtype rules: list[~azure.mgmt.monitor.v2022_10_01.models.ScaleRule] - :keyword fixed_date: the specific date-time for the profile. This element is not used if the - Recurrence element is used. - :paramtype fixed_date: ~azure.mgmt.monitor.v2022_10_01.models.TimeWindow - :keyword recurrence: the repeating times at which this profile begins. This element is not used - if the FixedDate element is used. - :paramtype recurrence: ~azure.mgmt.monitor.v2022_10_01.models.Recurrence - """ - super().__init__(**kwargs) - self.name = name - self.capacity = capacity - self.rules = rules - self.fixed_date = fixed_date - self.recurrence = recurrence - - -class Resource(_serialization.Model): - """The autoscale setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can - be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags - can be provided for a resource. Each tag must have a key no greater in length than 128 - characters and a value no greater in length than 256 characters. - :vartype tags: dict[str, str] - :ivar system_data: The system metadata related to the response. - :vartype system_data: ~azure.mgmt.monitor.v2022_10_01.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags - can be used in viewing and grouping this resource (across resource groups). A maximum of 15 - tags can be provided for a resource. Each tag must have a key no greater in length than 128 - characters and a value no greater in length than 256 characters. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - self.system_data = None - - -class AutoscaleSettingResource(Resource): # pylint: disable=too-many-instance-attributes - """The autoscale setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can - be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags - can be provided for a resource. Each tag must have a key no greater in length than 128 - characters and a value no greater in length than 256 characters. - :vartype tags: dict[str, str] - :ivar system_data: The system metadata related to the response. - :vartype system_data: ~azure.mgmt.monitor.v2022_10_01.models.SystemData - :ivar profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. Required. - :vartype profiles: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleProfile] - :ivar notifications: the collection of notifications. - :vartype notifications: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleNotification] - :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :vartype enabled: bool - :ivar predictive_autoscale_policy: the predictive autoscale policy mode. - :vartype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2022_10_01.models.PredictiveAutoscalePolicy - :ivar name_properties_name: the name of the autoscale setting. - :vartype name_properties_name: str - :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting - should be added to. - :vartype target_resource_uri: str - :ivar target_resource_location: the location of the resource that the autoscale setting should - be added to. - :vartype target_resource_location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "system_data": {"readonly": True}, - "profiles": {"required": True, "max_items": 20, "min_items": 0}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, - "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "predictive_autoscale_policy": { - "key": "properties.predictiveAutoscalePolicy", - "type": "PredictiveAutoscalePolicy", - }, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, - "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - profiles: List["_models.AutoscaleProfile"], - tags: Optional[Dict[str, str]] = None, - notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: bool = False, - predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, - name_properties_name: Optional[str] = None, - target_resource_uri: Optional[str] = None, - target_resource_location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags - can be used in viewing and grouping this resource (across resource groups). A maximum of 15 - tags can be provided for a resource. Each tag must have a key no greater in length than 128 - characters and a value no greater in length than 256 characters. - :paramtype tags: dict[str, str] - :keyword profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. Required. - :paramtype profiles: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleProfile] - :keyword notifications: the collection of notifications. - :paramtype notifications: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleNotification] - :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :paramtype enabled: bool - :keyword predictive_autoscale_policy: the predictive autoscale policy mode. - :paramtype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2022_10_01.models.PredictiveAutoscalePolicy - :keyword name_properties_name: the name of the autoscale setting. - :paramtype name_properties_name: str - :keyword target_resource_uri: the resource identifier of the resource that the autoscale - setting should be added to. - :paramtype target_resource_uri: str - :keyword target_resource_location: the location of the resource that the autoscale setting - should be added to. - :paramtype target_resource_location: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.profiles = profiles - self.notifications = notifications - self.enabled = enabled - self.predictive_autoscale_policy = predictive_autoscale_policy - self.name_properties_name = name_properties_name - self.target_resource_uri = target_resource_uri - self.target_resource_location = target_resource_location - - -class AutoscaleSettingResourceCollection(_serialization.Model): - """Represents a collection of autoscale setting resources. - - All required parameters must be populated in order to send to Azure. - - :ivar value: the values for the autoscale setting resources. Required. - :vartype value: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource] - :ivar next_link: URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AutoscaleSettingResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: the values for the autoscale setting resources. Required. - :paramtype value: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource] - :keyword next_link: URL to get the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AutoscaleSettingResourcePatch(_serialization.Model): - """The autoscale setting object for patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. - :vartype profiles: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleProfile] - :ivar notifications: the collection of notifications. - :vartype notifications: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleNotification] - :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :vartype enabled: bool - :ivar predictive_autoscale_policy: the predictive autoscale policy mode. - :vartype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2022_10_01.models.PredictiveAutoscalePolicy - :ivar name: the name of the autoscale setting. - :vartype name: str - :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting - should be added to. - :vartype target_resource_uri: str - :ivar target_resource_location: the location of the resource that the autoscale setting should - be added to. - :vartype target_resource_location: str - """ - - _validation = { - "profiles": {"max_items": 20, "min_items": 0}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "profiles": {"key": "properties.profiles", "type": "[AutoscaleProfile]"}, - "notifications": {"key": "properties.notifications", "type": "[AutoscaleNotification]"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "predictive_autoscale_policy": { - "key": "properties.predictiveAutoscalePolicy", - "type": "PredictiveAutoscalePolicy", - }, - "name": {"key": "properties.name", "type": "str"}, - "target_resource_uri": {"key": "properties.targetResourceUri", "type": "str"}, - "target_resource_location": {"key": "properties.targetResourceLocation", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - profiles: Optional[List["_models.AutoscaleProfile"]] = None, - notifications: Optional[List["_models.AutoscaleNotification"]] = None, - enabled: bool = False, - predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, - name: Optional[str] = None, - target_resource_uri: Optional[str] = None, - target_resource_location: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword profiles: the collection of automatic scaling profiles that specify different scaling - parameters for different time periods. A maximum of 20 profiles can be specified. - :paramtype profiles: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleProfile] - :keyword notifications: the collection of notifications. - :paramtype notifications: list[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleNotification] - :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'false'. - :paramtype enabled: bool - :keyword predictive_autoscale_policy: the predictive autoscale policy mode. - :paramtype predictive_autoscale_policy: - ~azure.mgmt.monitor.v2022_10_01.models.PredictiveAutoscalePolicy - :keyword name: the name of the autoscale setting. - :paramtype name: str - :keyword target_resource_uri: the resource identifier of the resource that the autoscale - setting should be added to. - :paramtype target_resource_uri: str - :keyword target_resource_location: the location of the resource that the autoscale setting - should be added to. - :paramtype target_resource_location: str - """ - super().__init__(**kwargs) - self.tags = tags - self.profiles = profiles - self.notifications = notifications - self.enabled = enabled - self.predictive_autoscale_policy = predictive_autoscale_policy - self.name = name - self.target_resource_uri = target_resource_uri - self.target_resource_location = target_resource_location - - -class EmailNotification(_serialization.Model): - """Email notification of an autoscale event. - - :ivar send_to_subscription_administrator: a value indicating whether to send email to - subscription administrator. - :vartype send_to_subscription_administrator: bool - :ivar send_to_subscription_co_administrators: a value indicating whether to send email to - subscription co-administrators. - :vartype send_to_subscription_co_administrators: bool - :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case - this attribute will be ignored. - :vartype custom_emails: list[str] - """ - - _attribute_map = { - "send_to_subscription_administrator": {"key": "sendToSubscriptionAdministrator", "type": "bool"}, - "send_to_subscription_co_administrators": {"key": "sendToSubscriptionCoAdministrators", "type": "bool"}, - "custom_emails": {"key": "customEmails", "type": "[str]"}, - } - - def __init__( - self, - *, - send_to_subscription_administrator: bool = False, - send_to_subscription_co_administrators: bool = False, - custom_emails: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword send_to_subscription_administrator: a value indicating whether to send email to - subscription administrator. - :paramtype send_to_subscription_administrator: bool - :keyword send_to_subscription_co_administrators: a value indicating whether to send email to - subscription co-administrators. - :paramtype send_to_subscription_co_administrators: bool - :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case - this attribute will be ignored. - :paramtype custom_emails: list[str] - """ - super().__init__(**kwargs) - self.send_to_subscription_administrator = send_to_subscription_administrator - self.send_to_subscription_co_administrators = send_to_subscription_co_administrators - self.custom_emails = custom_emails - - -class MetricTrigger(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The trigger that results in a scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar metric_name: the name of the metric that defines what the rule monitors. Required. - :vartype metric_name: str - :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. - :vartype metric_namespace: str - :ivar metric_resource_uri: the resource identifier of the resource the rule monitors. Required. - :vartype metric_resource_uri: str - :ivar metric_resource_location: the location of the resource the rule monitors. - :vartype metric_resource_location: str - :ivar time_grain: 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. - Required. - :vartype time_grain: ~datetime.timedelta - :ivar statistic: the metric statistic type. How the metrics from multiple instances are - combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". - :vartype statistic: str or ~azure.mgmt.monitor.v2022_10_01.models.MetricStatisticType - :ivar time_window: 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. Required. - :vartype time_window: ~datetime.timedelta - :ivar time_aggregation: time aggregation type. How the data that is collected should be - combined over time. The default value is Average. Required. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", and "Last". - :vartype time_aggregation: str or ~azure.mgmt.monitor.v2022_10_01.models.TimeAggregationType - :ivar operator: the operator that is used to compare the metric data and the threshold. - Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :vartype operator: str or ~azure.mgmt.monitor.v2022_10_01.models.ComparisonOperationType - :ivar threshold: the threshold of the metric that triggers the scale action. Required. - :vartype threshold: float - :ivar dimensions: List of dimension conditions. For example: - [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :vartype dimensions: list[~azure.mgmt.monitor.v2022_10_01.models.ScaleRuleMetricDimension] - :ivar divide_per_instance: a value indicating whether metric should divide per instance. - :vartype divide_per_instance: bool - """ - - _validation = { - "metric_name": {"required": True}, - "metric_resource_uri": {"required": True}, - "time_grain": {"required": True}, - "statistic": {"required": True}, - "time_window": {"required": True}, - "time_aggregation": {"required": True}, - "operator": {"required": True}, - "threshold": {"required": True}, - } - - _attribute_map = { - "metric_name": {"key": "metricName", "type": "str"}, - "metric_namespace": {"key": "metricNamespace", "type": "str"}, - "metric_resource_uri": {"key": "metricResourceUri", "type": "str"}, - "metric_resource_location": {"key": "metricResourceLocation", "type": "str"}, - "time_grain": {"key": "timeGrain", "type": "duration"}, - "statistic": {"key": "statistic", "type": "str"}, - "time_window": {"key": "timeWindow", "type": "duration"}, - "time_aggregation": {"key": "timeAggregation", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "threshold": {"key": "threshold", "type": "float"}, - "dimensions": {"key": "dimensions", "type": "[ScaleRuleMetricDimension]"}, - "divide_per_instance": {"key": "dividePerInstance", "type": "bool"}, - } - - def __init__( - self, - *, - metric_name: str, - metric_resource_uri: str, - time_grain: datetime.timedelta, - statistic: Union[str, "_models.MetricStatisticType"], - time_window: datetime.timedelta, - time_aggregation: Union[str, "_models.TimeAggregationType"], - operator: Union[str, "_models.ComparisonOperationType"], - threshold: float, - metric_namespace: Optional[str] = None, - metric_resource_location: Optional[str] = None, - dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, - divide_per_instance: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric_name: the name of the metric that defines what the rule monitors. Required. - :paramtype metric_name: str - :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. - :paramtype metric_namespace: str - :keyword metric_resource_uri: the resource identifier of the resource the rule monitors. - Required. - :paramtype metric_resource_uri: str - :keyword metric_resource_location: the location of the resource the rule monitors. - :paramtype metric_resource_location: str - :keyword time_grain: 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. Required. - :paramtype time_grain: ~datetime.timedelta - :keyword statistic: the metric statistic type. How the metrics from multiple instances are - combined. Required. Known values are: "Average", "Min", "Max", "Sum", and "Count". - :paramtype statistic: str or ~azure.mgmt.monitor.v2022_10_01.models.MetricStatisticType - :keyword time_window: 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. Required. - :paramtype time_window: ~datetime.timedelta - :keyword time_aggregation: time aggregation type. How the data that is collected should be - combined over time. The default value is Average. Required. Known values are: "Average", - "Minimum", "Maximum", "Total", "Count", and "Last". - :paramtype time_aggregation: str or ~azure.mgmt.monitor.v2022_10_01.models.TimeAggregationType - :keyword operator: the operator that is used to compare the metric data and the threshold. - Required. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", - "LessThan", and "LessThanOrEqual". - :paramtype operator: str or ~azure.mgmt.monitor.v2022_10_01.models.ComparisonOperationType - :keyword threshold: the threshold of the metric that triggers the scale action. Required. - :paramtype threshold: float - :keyword dimensions: List of dimension conditions. For example: - [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :paramtype dimensions: list[~azure.mgmt.monitor.v2022_10_01.models.ScaleRuleMetricDimension] - :keyword divide_per_instance: a value indicating whether metric should divide per instance. - :paramtype divide_per_instance: bool - """ - super().__init__(**kwargs) - self.metric_name = metric_name - self.metric_namespace = metric_namespace - self.metric_resource_uri = metric_resource_uri - self.metric_resource_location = metric_resource_location - self.time_grain = time_grain - self.statistic = statistic - self.time_window = time_window - self.time_aggregation = time_aggregation - self.operator = operator - self.threshold = threshold - self.dimensions = dimensions - self.divide_per_instance = divide_per_instance - - -class PredictiveAutoscalePolicy(_serialization.Model): - """The parameters for enabling predictive autoscale. - - All required parameters must be populated in order to send to Azure. - - :ivar scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", - "ForecastOnly", and "Enabled". - :vartype scale_mode: str or - ~azure.mgmt.monitor.v2022_10_01.models.PredictiveAutoscalePolicyScaleMode - :ivar scale_look_ahead_time: the amount of time to specify by which instances are launched in - advance. It must be between 1 minute and 60 minutes in ISO 8601 format. - :vartype scale_look_ahead_time: ~datetime.timedelta - """ - - _validation = { - "scale_mode": {"required": True}, - } - - _attribute_map = { - "scale_mode": {"key": "scaleMode", "type": "str"}, - "scale_look_ahead_time": {"key": "scaleLookAheadTime", "type": "duration"}, - } - - def __init__( - self, - *, - scale_mode: Union[str, "_models.PredictiveAutoscalePolicyScaleMode"], - scale_look_ahead_time: Optional[datetime.timedelta] = None, - **kwargs: Any - ) -> None: - """ - :keyword scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", - "ForecastOnly", and "Enabled". - :paramtype scale_mode: str or - ~azure.mgmt.monitor.v2022_10_01.models.PredictiveAutoscalePolicyScaleMode - :keyword scale_look_ahead_time: the amount of time to specify by which instances are launched - in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. - :paramtype scale_look_ahead_time: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.scale_mode = scale_mode - self.scale_look_ahead_time = scale_look_ahead_time - - -class PredictiveResponse(_serialization.Model): - """The response to a metrics query. - - :ivar timespan: 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. - :vartype timespan: str - :ivar interval: 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. - :vartype interval: ~datetime.timedelta - :ivar metric_name: The metrics being queried. - :vartype metric_name: str - :ivar target_resource_id: resource of the predictive metric. - :vartype target_resource_id: str - :ivar data: the value of the collection. - :vartype data: list[~azure.mgmt.monitor.v2022_10_01.models.PredictiveValue] - """ - - _attribute_map = { - "timespan": {"key": "timespan", "type": "str"}, - "interval": {"key": "interval", "type": "duration"}, - "metric_name": {"key": "metricName", "type": "str"}, - "target_resource_id": {"key": "targetResourceId", "type": "str"}, - "data": {"key": "data", "type": "[PredictiveValue]"}, - } - - def __init__( - self, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - metric_name: Optional[str] = None, - target_resource_id: Optional[str] = None, - data: Optional[List["_models.PredictiveValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword timespan: 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. - :paramtype timespan: str - :keyword interval: 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. - :paramtype interval: ~datetime.timedelta - :keyword metric_name: The metrics being queried. - :paramtype metric_name: str - :keyword target_resource_id: resource of the predictive metric. - :paramtype target_resource_id: str - :keyword data: the value of the collection. - :paramtype data: list[~azure.mgmt.monitor.v2022_10_01.models.PredictiveValue] - """ - super().__init__(**kwargs) - self.timespan = timespan - self.interval = interval - self.metric_name = metric_name - self.target_resource_id = target_resource_id - self.data = data - - -class PredictiveValue(_serialization.Model): - """Represents a predictive metric value in the given bucket. - - All required parameters must be populated in order to send to Azure. - - :ivar time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :vartype time_stamp: ~datetime.datetime - :ivar value: Predictive value in this time bucket. Required. - :vartype value: float - """ - - _validation = { - "time_stamp": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, - "value": {"key": "value", "type": "float"}, - } - - def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs: Any) -> None: - """ - :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. - :paramtype time_stamp: ~datetime.datetime - :keyword value: Predictive value in this time bucket. Required. - :paramtype value: float - """ - super().__init__(**kwargs) - self.time_stamp = time_stamp - self.value = value - - -class Recurrence(_serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate - element is used. - - All required parameters must be populated in order to send to Azure. - - :ivar frequency: 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. Required. Known values are: "None", "Second", - "Minute", "Hour", "Day", "Week", "Month", and "Year". - :vartype frequency: str or ~azure.mgmt.monitor.v2022_10_01.models.RecurrenceFrequency - :ivar schedule: the scheduling constraints for when the profile begins. Required. - :vartype schedule: ~azure.mgmt.monitor.v2022_10_01.models.RecurrentSchedule - """ - - _validation = { - "frequency": {"required": True}, - "schedule": {"required": True}, - } - - _attribute_map = { - "frequency": {"key": "frequency", "type": "str"}, - "schedule": {"key": "schedule", "type": "RecurrentSchedule"}, - } - - def __init__( - self, - *, - frequency: Union[str, "_models.RecurrenceFrequency"], - schedule: "_models.RecurrentSchedule", - **kwargs: Any - ) -> None: - """ - :keyword frequency: 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. Required. Known values are: "None", - "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year". - :paramtype frequency: str or ~azure.mgmt.monitor.v2022_10_01.models.RecurrenceFrequency - :keyword schedule: the scheduling constraints for when the profile begins. Required. - :paramtype schedule: ~azure.mgmt.monitor.v2022_10_01.models.RecurrentSchedule - """ - super().__init__(**kwargs) - self.frequency = frequency - self.schedule = schedule - - -class RecurrentSchedule(_serialization.Model): - """The scheduling constraints for when the profile begins. - - All required parameters must be populated in order to send to Azure. - - :ivar time_zone: 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. Required. - :vartype time_zone: str - :ivar days: the collection of days that the profile takes effect on. Possible values are Sunday - through Saturday. Required. - :vartype days: list[str] - :ivar hours: 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). Required. - :vartype hours: list[int] - :ivar minutes: A collection of minutes at which the profile takes effect at. Required. - :vartype minutes: list[int] - """ - - _validation = { - "time_zone": {"required": True}, - "days": {"required": True}, - "hours": {"required": True}, - "minutes": {"required": True}, - } - - _attribute_map = { - "time_zone": {"key": "timeZone", "type": "str"}, - "days": {"key": "days", "type": "[str]"}, - "hours": {"key": "hours", "type": "[int]"}, - "minutes": {"key": "minutes", "type": "[int]"}, - } - - def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any) -> None: - """ - :keyword time_zone: 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. Required. - :paramtype time_zone: str - :keyword days: the collection of days that the profile takes effect on. Possible values are - Sunday through Saturday. Required. - :paramtype days: list[str] - :keyword hours: 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). Required. - :paramtype hours: list[int] - :keyword minutes: A collection of minutes at which the profile takes effect at. Required. - :paramtype minutes: list[int] - """ - super().__init__(**kwargs) - self.time_zone = time_zone - self.days = days - self.hours = hours - self.minutes = minutes - - -class ScaleAction(_serialization.Model): - """The parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar direction: the scale direction. Whether the scaling action increases or decreases the - number of instances. Required. Known values are: "None", "Increase", and "Decrease". - :vartype direction: str or ~azure.mgmt.monitor.v2022_10_01.models.ScaleDirection - :ivar type: the type of action that should occur when the scale rule fires. Required. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". - :vartype type: str or ~azure.mgmt.monitor.v2022_10_01.models.ScaleType - :ivar value: the number of instances that are involved in the scaling action. This value must - be 1 or greater. The default value is 1. - :vartype value: str - :ivar cooldown: 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. Required. - :vartype cooldown: ~datetime.timedelta - """ - - _validation = { - "direction": {"required": True}, - "type": {"required": True}, - "cooldown": {"required": True}, - } - - _attribute_map = { - "direction": {"key": "direction", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "cooldown": {"key": "cooldown", "type": "duration"}, - } - - def __init__( - self, - *, - direction: Union[str, "_models.ScaleDirection"], - type: Union[str, "_models.ScaleType"], - cooldown: datetime.timedelta, - value: str = "1", - **kwargs: Any - ) -> None: - """ - :keyword direction: the scale direction. Whether the scaling action increases or decreases the - number of instances. Required. Known values are: "None", "Increase", and "Decrease". - :paramtype direction: str or ~azure.mgmt.monitor.v2022_10_01.models.ScaleDirection - :keyword type: the type of action that should occur when the scale rule fires. Required. Known - values are: "ChangeCount", "PercentChangeCount", "ExactCount", and "ServiceAllowedNextValue". - :paramtype type: str or ~azure.mgmt.monitor.v2022_10_01.models.ScaleType - :keyword value: the number of instances that are involved in the scaling action. This value - must be 1 or greater. The default value is 1. - :paramtype value: str - :keyword cooldown: 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. Required. - :paramtype cooldown: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.direction = direction - self.type = type - self.value = value - self.cooldown = cooldown - - -class ScaleCapacity(_serialization.Model): - """The number of instances that can be used during this profile. - - All required parameters must be populated in order to send to Azure. - - :ivar minimum: the minimum number of instances for the resource. Required. - :vartype minimum: str - :ivar maximum: 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. Required. - :vartype maximum: str - :ivar default: 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. - Required. - :vartype default: str - """ - - _validation = { - "minimum": {"required": True}, - "maximum": {"required": True}, - "default": {"required": True}, - } - - _attribute_map = { - "minimum": {"key": "minimum", "type": "str"}, - "maximum": {"key": "maximum", "type": "str"}, - "default": {"key": "default", "type": "str"}, - } - - def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs: Any) -> None: - """ - :keyword minimum: the minimum number of instances for the resource. Required. - :paramtype minimum: str - :keyword maximum: 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. Required. - :paramtype maximum: str - :keyword default: 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. - Required. - :paramtype default: str - """ - super().__init__(**kwargs) - self.minimum = minimum - self.maximum = maximum - self.default = default - - -class ScaleRule(_serialization.Model): - """A rule that provide the triggers and parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :ivar metric_trigger: the trigger that results in a scaling action. Required. - :vartype metric_trigger: ~azure.mgmt.monitor.v2022_10_01.models.MetricTrigger - :ivar scale_action: the parameters for the scaling action. Required. - :vartype scale_action: ~azure.mgmt.monitor.v2022_10_01.models.ScaleAction - """ - - _validation = { - "metric_trigger": {"required": True}, - "scale_action": {"required": True}, - } - - _attribute_map = { - "metric_trigger": {"key": "metricTrigger", "type": "MetricTrigger"}, - "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, - } - - def __init__( - self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs: Any - ) -> None: - """ - :keyword metric_trigger: the trigger that results in a scaling action. Required. - :paramtype metric_trigger: ~azure.mgmt.monitor.v2022_10_01.models.MetricTrigger - :keyword scale_action: the parameters for the scaling action. Required. - :paramtype scale_action: ~azure.mgmt.monitor.v2022_10_01.models.ScaleAction - """ - super().__init__(**kwargs) - self.metric_trigger = metric_trigger - self.scale_action = scale_action - - -class ScaleRuleMetricDimension(_serialization.Model): - """Specifies an auto scale rule metric dimension. - - All required parameters must be populated in order to send to Azure. - - :ivar dimension_name: Name of the dimension. Required. - :vartype dimension_name: str - :ivar operator: 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. Required. - Known values are: "Equals" and "NotEquals". - :vartype operator: str or - ~azure.mgmt.monitor.v2022_10_01.models.ScaleRuleMetricDimensionOperationType - :ivar values: list of dimension values. For example: ["App1","App2"]. Required. - :vartype values: list[str] - """ - - _validation = { - "dimension_name": {"required": True}, - "operator": {"required": True}, - "values": {"required": True}, - } - - _attribute_map = { - "dimension_name": {"key": "DimensionName", "type": "str"}, - "operator": {"key": "Operator", "type": "str"}, - "values": {"key": "Values", "type": "[str]"}, - } - - def __init__( - self, - *, - dimension_name: str, - operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], - values: List[str], - **kwargs: Any - ) -> None: - """ - :keyword dimension_name: Name of the dimension. Required. - :paramtype dimension_name: str - :keyword operator: 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. - Required. Known values are: "Equals" and "NotEquals". - :paramtype operator: str or - ~azure.mgmt.monitor.v2022_10_01.models.ScaleRuleMetricDimensionOperationType - :keyword values: list of dimension values. For example: ["App1","App2"]. Required. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.dimension_name = dimension_name - self.operator = operator - self.values = values - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.monitor.v2022_10_01.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_10_01.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.monitor.v2022_10_01.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.monitor.v2022_10_01.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TimeWindow(_serialization.Model): - """A specific date-time for the profile. - - All required parameters must be populated in order to send to Azure. - - :ivar time_zone: 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. - :vartype time_zone: str - :ivar start: the start time for the profile in ISO 8601 format. Required. - :vartype start: ~datetime.datetime - :ivar end: the end time for the profile in ISO 8601 format. Required. - :vartype end: ~datetime.datetime - """ - - _validation = { - "start": {"required": True}, - "end": {"required": True}, - } - - _attribute_map = { - "time_zone": {"key": "timeZone", "type": "str"}, - "start": {"key": "start", "type": "iso-8601"}, - "end": {"key": "end", "type": "iso-8601"}, - } - - def __init__( - self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword time_zone: 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. - :paramtype time_zone: str - :keyword start: the start time for the profile in ISO 8601 format. Required. - :paramtype start: ~datetime.datetime - :keyword end: the end time for the profile in ISO 8601 format. Required. - :paramtype end: ~datetime.datetime - """ - super().__init__(**kwargs) - self.time_zone = time_zone - self.start = start - self.end = end - - -class WebhookNotification(_serialization.Model): - """Webhook notification of an autoscale event. - - :ivar service_uri: the service address to receive the notification. - :vartype service_uri: str - :ivar properties: a property bag of settings. This value can be empty. - :vartype properties: dict[str, str] - """ - - _attribute_map = { - "service_uri": {"key": "serviceUri", "type": "str"}, - "properties": {"key": "properties", "type": "{str}"}, - } - - def __init__( - self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> None: - """ - :keyword service_uri: the service address to receive the notification. - :paramtype service_uri: str - :keyword properties: a property bag of settings. This value can be empty. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.service_uri = service_uri - self.properties = properties diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 57efeee770893..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the operator that is used to compare the metric data and the threshold.""" - - EQUALS = "Equals" - NOT_EQUALS = "NotEquals" - GREATER_THAN = "GreaterThan" - GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" - LESS_THAN = "LessThan" - LESS_THAN_OR_EQUAL = "LessThanOrEqual" - - -class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - - -class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the metric statistic type. How the metrics from multiple instances are combined.""" - - AVERAGE = "Average" - MIN = "Min" - MAX = "Max" - SUM = "Sum" - COUNT = "Count" - - -class PredictiveAutoscalePolicyScaleMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the predictive autoscale mode.""" - - DISABLED = "Disabled" - FORECAST_ONLY = "ForecastOnly" - ENABLED = "Enabled" - - -class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - NONE = "None" - SECOND = "Second" - MINUTE = "Minute" - HOUR = "Hour" - DAY = "Day" - WEEK = "Week" - MONTH = "Month" - YEAR = "Year" - - -class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the scale direction. Whether the scaling action increases or decreases the number of instances.""" - - NONE = "None" - INCREASE = "Increase" - DECREASE = "Decrease" - - -class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - EQUALS = "Equals" - NOT_EQUALS = "NotEquals" - - -class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the type of action that should occur when the scale rule fires.""" - - CHANGE_COUNT = "ChangeCount" - PERCENT_CHANGE_COUNT = "PercentChangeCount" - EXACT_COUNT = "ExactCount" - SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" - - -class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """time aggregation type. How the data that is collected should be combined over time. The default - value is Average. - """ - - AVERAGE = "Average" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" - COUNT = "Count" - LAST = "Last" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/__init__.py deleted file mode 100644 index 3d1ab289551f4..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._autoscale_settings_operations import AutoscaleSettingsOperations -from ._predictive_metric_operations import PredictiveMetricOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AutoscaleSettingsOperations", - "PredictiveMetricOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_autoscale_settings_operations.py deleted file mode 100644 index eb8a0947cdab9..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_autoscale_settings_operations.py +++ /dev/null @@ -1,845 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, autoscale_setting_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AutoscaleSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_10_01.MonitorManagementClient`'s - :attr:`autoscale_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" - } - - @overload - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: _models.AutoscaleSettingResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - autoscale_setting_name: str, - parameters: Union[_models.AutoscaleSettingResource, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Creates or updates an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "AutoscaleSettingResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> None: - """Deletes and autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def get( - self, resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Gets an autoscale setting. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @overload - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResourcePatch - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Required. - :type autoscale_setting_resource: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - autoscale_setting_name: str, - autoscale_setting_resource: Union[_models.AutoscaleSettingResourcePatch, IO], - **kwargs: Any - ) -> _models.AutoscaleSettingResource: - """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate - method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a - AutoscaleSettingResourcePatch type or a IO type. Required. - :type autoscale_setting_resource: - ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResourcePatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoscaleSettingResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(autoscale_setting_resource, (IO, bytes)): - _content = autoscale_setting_resource - else: - _json = self._serialize.body(autoscale_setting_resource, "AutoscaleSettingResourcePatch") - - request = build_update_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" - } - - @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: - """Lists the autoscale settings for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2022_10_01.models.AutoscaleSettingResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_predictive_metric_operations.py deleted file mode 100644 index d1f57c131d605..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_predictive_metric_operations.py +++ /dev/null @@ -1,193 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -import datetime -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - autoscale_setting_name: str, - subscription_id: str, - *, - timespan: str, - interval: datetime.timedelta, - metric_namespace: str, - metric_name: str, - aggregation: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - _params["metricNamespace"] = _SERIALIZER.query("metric_namespace", metric_namespace, "str") - _params["metricName"] = _SERIALIZER.query("metric_name", metric_name, "str") - _params["aggregation"] = _SERIALIZER.query("aggregation", aggregation, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PredictiveMetricOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2022_10_01.MonitorManagementClient`'s - :attr:`predictive_metric` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - autoscale_setting_name: str, - timespan: str, - interval: datetime.timedelta, - metric_namespace: str, - metric_name: str, - aggregation: str, - **kwargs: Any - ) -> _models.PredictiveResponse: - """get predictive autoscale metric future data. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param autoscale_setting_name: The autoscale setting name. Required. - :type autoscale_setting_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. Required. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. Required. - :type interval: ~datetime.timedelta - :param metric_namespace: Metric namespace to query metric definitions for. Required. - :type metric_namespace: str - :param metric_name: 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'**. Required. - :type metric_name: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. Required. - :type aggregation: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PredictiveResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2022_10_01.models.PredictiveResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) - cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - autoscale_setting_name=autoscale_setting_name, - subscription_id=self._config.subscription_id, - timespan=timespan, - interval=interval, - metric_namespace=metric_namespace, - metric_name=metric_name, - aggregation=aggregation, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PredictiveResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_configuration.py deleted file mode 100644 index 44706f982b49a..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_metadata.json deleted file mode 100644 index dd4f1ef7423e5..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2023-01-01", - "total_api_version_list": ["2023-01-01"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "action_groups": "ActionGroupsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_monitor_management_client.py deleted file mode 100644 index 2df565f22f594..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_monitor_management_client.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2023_01_01.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_configuration.py deleted file mode 100644 index dde84c5326243..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-01-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_monitor_management_client.py deleted file mode 100644 index e729b5d59b3f1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_monitor_management_client.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: azure.mgmt.monitor.v2023_01_01.aio.operations.ActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/_action_groups_operations.py deleted file mode 100644 index 0b64afbb9f895..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/_action_groups_operations.py +++ /dev/null @@ -1,1100 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._action_groups_operations import ( - build_create_notifications_at_action_group_resource_level_request, - build_create_or_update_request, - build_delete_request, - build_enable_receiver_request, - build_get_request, - build_get_test_notifications_at_action_group_resource_level_request, - build_list_by_resource_group_request, - build_list_by_subscription_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2023_01_01.aio.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - async def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_action_group_resource_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @overload - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2023_01_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2023_01_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_notifications_at_action_group_resource_level_initial( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @distributed_trace_async - async def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2023_01_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2023_01_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/__init__.py deleted file mode 100644 index b1dac637c4030..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionDetail -from ._models_py3 import ActionGroupList -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import ActionGroupResource -from ._models_py3 import ArmRoleReceiver -from ._models_py3 import AutomationRunbookReceiver -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import AzureResource -from ._models_py3 import Context -from ._models_py3 import EmailReceiver -from ._models_py3 import EnableRequest -from ._models_py3 import ErrorResponse -from ._models_py3 import EventHubReceiver -from ._models_py3 import ItsmReceiver -from ._models_py3 import LogicAppReceiver -from ._models_py3 import NotificationRequestBody -from ._models_py3 import SmsReceiver -from ._models_py3 import TestNotificationDetailsResponse -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionDetail", - "ActionGroupList", - "ActionGroupPatchBody", - "ActionGroupResource", - "ArmRoleReceiver", - "AutomationRunbookReceiver", - "AzureAppPushReceiver", - "AzureFunctionReceiver", - "AzureResource", - "Context", - "EmailReceiver", - "EnableRequest", - "ErrorResponse", - "EventHubReceiver", - "ItsmReceiver", - "LogicAppReceiver", - "NotificationRequestBody", - "SmsReceiver", - "TestNotificationDetailsResponse", - "VoiceReceiver", - "WebhookReceiver", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_models_py3.py deleted file mode 100644 index f75c74e4eec65..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_models_py3.py +++ /dev/null @@ -1,1240 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionDetail(_serialization.Model): - """The action detail. - - :ivar mechanism_type: The mechanism type. - :vartype mechanism_type: str - :ivar name: The name of the action. - :vartype name: str - :ivar status: The status of the action. - :vartype status: str - :ivar sub_state: The substatus of the action. - :vartype sub_state: str - :ivar send_time: The send time. - :vartype send_time: str - :ivar detail: The detail of the friendly error message. - :vartype detail: str - """ - - _attribute_map = { - "mechanism_type": {"key": "MechanismType", "type": "str"}, - "name": {"key": "Name", "type": "str"}, - "status": {"key": "Status", "type": "str"}, - "sub_state": {"key": "SubState", "type": "str"}, - "send_time": {"key": "SendTime", "type": "str"}, - "detail": {"key": "Detail", "type": "str"}, - } - - def __init__( - self, - *, - mechanism_type: Optional[str] = None, - name: Optional[str] = None, - status: Optional[str] = None, - sub_state: Optional[str] = None, - send_time: Optional[str] = None, - detail: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword mechanism_type: The mechanism type. - :paramtype mechanism_type: str - :keyword name: The name of the action. - :paramtype name: str - :keyword status: The status of the action. - :paramtype status: str - :keyword sub_state: The substatus of the action. - :paramtype sub_state: str - :keyword send_time: The send time. - :paramtype send_time: str - :keyword detail: The detail of the friendly error message. - :paramtype detail: str - """ - super().__init__(**kwargs) - self.mechanism_type = mechanism_type - self.name = name - self.status = status - self.sub_state = sub_state - self.send_time = send_time - self.detail = detail - - -class ActionGroupList(_serialization.Model): - """A list of action groups. - - :ivar value: The list of action groups. - :vartype value: list[~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of action groups. - :paramtype value: list[~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ActionGroupPatchBody(_serialization.Model): - """An action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class AzureResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class ActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EventHubReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "properties.itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": { - "key": "properties.automationRunbookReceivers", - "type": "[AutomationRunbookReceiver]", - }, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "properties.logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "properties.azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "properties.armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "properties.eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this action group is enabled. If an action group is not - enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EventHubReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class ArmRoleReceiver(_serialization.Model): - """An arm role receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the arm role receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar role_id: The arm role id. Required. - :vartype role_id: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "role_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "role_id": {"key": "roleId", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the arm role receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword role_id: The arm role id. Required. - :paramtype role_id: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.role_id = role_id - self.use_common_alert_schema = use_common_alert_schema - - -class AutomationRunbookReceiver(_serialization.Model): - """The Azure Automation Runbook notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :vartype automation_account_id: str - :ivar runbook_name: The name for this runbook. Required. - :vartype runbook_name: str - :ivar webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :vartype webhook_resource_id: str - :ivar is_global_runbook: Indicates whether this instance is global runbook. Required. - :vartype is_global_runbook: bool - :ivar name: Indicates name of the webhook. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "automation_account_id": {"required": True}, - "runbook_name": {"required": True}, - "webhook_resource_id": {"required": True}, - "is_global_runbook": {"required": True}, - } - - _attribute_map = { - "automation_account_id": {"key": "automationAccountId", "type": "str"}, - "runbook_name": {"key": "runbookName", "type": "str"}, - "webhook_resource_id": {"key": "webhookResourceId", "type": "str"}, - "is_global_runbook": {"key": "isGlobalRunbook", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - automation_account_id: str, - runbook_name: str, - webhook_resource_id: str, - is_global_runbook: bool, - name: Optional[str] = None, - service_uri: Optional[str] = None, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword automation_account_id: The Azure automation account Id which holds this runbook and - authenticate to Azure resource. Required. - :paramtype automation_account_id: str - :keyword runbook_name: The name for this runbook. Required. - :paramtype runbook_name: str - :keyword webhook_resource_id: The resource id for webhook linked to this runbook. Required. - :paramtype webhook_resource_id: str - :keyword is_global_runbook: Indicates whether this instance is global runbook. Required. - :paramtype is_global_runbook: bool - :keyword name: Indicates name of the webhook. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.automation_account_id = automation_account_id - self.runbook_name = runbook_name - self.webhook_resource_id = webhook_resource_id - self.is_global_runbook = is_global_runbook - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureFunctionReceiver(_serialization.Model): - """An azure function receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the azure function receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar function_app_resource_id: The azure resource id of the function app. Required. - :vartype function_app_resource_id: str - :ivar function_name: The function name in the function app. Required. - :vartype function_name: str - :ivar http_trigger_url: The http trigger url where http request sent to. Required. - :vartype http_trigger_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "function_app_resource_id": {"required": True}, - "function_name": {"required": True}, - "http_trigger_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "function_app_resource_id": {"key": "functionAppResourceId", "type": "str"}, - "function_name": {"key": "functionName", "type": "str"}, - "http_trigger_url": {"key": "httpTriggerUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - function_app_resource_id: str, - function_name: str, - http_trigger_url: str, - use_common_alert_schema: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the azure function receiver. Names must be unique across all - receivers within an action group. Required. - :paramtype name: str - :keyword function_app_resource_id: The azure resource id of the function app. Required. - :paramtype function_app_resource_id: str - :keyword function_name: The function name in the function app. Required. - :paramtype function_name: str - :keyword http_trigger_url: The http trigger url where http request sent to. Required. - :paramtype http_trigger_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.function_app_resource_id = function_app_resource_id - self.function_name = function_name - self.http_trigger_url = http_trigger_url - self.use_common_alert_schema = use_common_alert_schema - - -class Context(_serialization.Model): - """The context info. - - :ivar notification_source: The source of the notification request. - :vartype notification_source: str - :ivar context_type: The context id type. - :vartype context_type: str - """ - - _attribute_map = { - "notification_source": {"key": "notificationSource", "type": "str"}, - "context_type": {"key": "contextType", "type": "str"}, - } - - def __init__( - self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword notification_source: The source of the notification request. - :paramtype notification_source: str - :keyword context_type: The context id type. - :paramtype context_type: str - """ - super().__init__(**kwargs) - self.notification_source = notification_source - self.context_type = context_type - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2023_01_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.use_common_alert_schema = use_common_alert_schema - self.status = None - - -class EnableRequest(_serialization.Model): - """Describes a receiver that should be resubscribed. - - All required parameters must be populated in order to send to Azure. - - :ivar receiver_name: The name of the receiver to resubscribe. Required. - :vartype receiver_name: str - """ - - _validation = { - "receiver_name": {"required": True}, - } - - _attribute_map = { - "receiver_name": {"key": "receiverName", "type": "str"}, - } - - def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: - """ - :keyword receiver_name: The name of the receiver to resubscribe. Required. - :paramtype receiver_name: str - """ - super().__init__(**kwargs) - self.receiver_name = receiver_name - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class EventHubReceiver(_serialization.Model): - """An Event hub receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar event_hub_name_space: The Event Hub namespace. Required. - :vartype event_hub_name_space: str - :ivar event_hub_name: The name of the specific Event Hub queue. Required. - :vartype event_hub_name: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar tenant_id: The tenant Id for the subscription containing this event hub. - :vartype tenant_id: str - :ivar subscription_id: The Id for the subscription containing this event hub. Required. - :vartype subscription_id: str - """ - - _validation = { - "name": {"required": True}, - "event_hub_name_space": {"required": True}, - "event_hub_name": {"required": True}, - "subscription_id": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "event_hub_name_space": {"key": "eventHubNameSpace", "type": "str"}, - "event_hub_name": {"key": "eventHubName", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - event_hub_name_space: str, - event_hub_name: str, - subscription_id: str, - use_common_alert_schema: bool = False, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Event hub receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword event_hub_name_space: The Event Hub namespace. Required. - :paramtype event_hub_name_space: str - :keyword event_hub_name: The name of the specific Event Hub queue. Required. - :paramtype event_hub_name: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword tenant_id: The tenant Id for the subscription containing this event hub. - :paramtype tenant_id: str - :keyword subscription_id: The Id for the subscription containing this event hub. Required. - :paramtype subscription_id: str - """ - super().__init__(**kwargs) - self.name = name - self.event_hub_name_space = event_hub_name_space - self.event_hub_name = event_hub_name - self.use_common_alert_schema = use_common_alert_schema - self.tenant_id = tenant_id - self.subscription_id = subscription_id - - -class ItsmReceiver(_serialization.Model): - """An Itsm receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Itsm receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar workspace_id: OMS LA instance identifier. Required. - :vartype workspace_id: str - :ivar connection_id: Unique identification of ITSM connection among multiple defined in above - workspace. Required. - :vartype connection_id: str - :ivar ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :vartype ticket_configuration: str - :ivar region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :vartype region: str - """ - - _validation = { - "name": {"required": True}, - "workspace_id": {"required": True}, - "connection_id": {"required": True}, - "ticket_configuration": {"required": True}, - "region": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "workspace_id": {"key": "workspaceId", "type": "str"}, - "connection_id": {"key": "connectionId", "type": "str"}, - "ticket_configuration": {"key": "ticketConfiguration", "type": "str"}, - "region": {"key": "region", "type": "str"}, - } - - def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword workspace_id: OMS LA instance identifier. Required. - :paramtype workspace_id: str - :keyword connection_id: Unique identification of ITSM connection among multiple defined in - above workspace. Required. - :paramtype connection_id: str - :keyword ticket_configuration: JSON blob for the configurations of the ITSM action. - CreateMultipleWorkItems option will be part of this blob as well. Required. - :paramtype ticket_configuration: str - :keyword region: Region in which workspace resides. Supported - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - Required. - :paramtype region: str - """ - super().__init__(**kwargs) - self.name = name - self.workspace_id = workspace_id - self.connection_id = connection_id - self.ticket_configuration = ticket_configuration - self.region = region - - -class LogicAppReceiver(_serialization.Model): - """A logic app receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :vartype name: str - :ivar resource_id: The azure resource id of the logic app receiver. Required. - :vartype resource_id: str - :ivar callback_url: The callback url where http request sent to. Required. - :vartype callback_url: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - """ - - _validation = { - "name": {"required": True}, - "resource_id": {"required": True}, - "callback_url": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "callback_url": {"key": "callbackUrl", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - } - - def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any - ) -> None: - """ - :keyword name: The name of the logic app receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword resource_id: The azure resource id of the logic app receiver. Required. - :paramtype resource_id: str - :keyword callback_url: The callback url where http request sent to. Required. - :paramtype callback_url: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.resource_id = resource_id - self.callback_url = callback_url - self.use_common_alert_schema = use_common_alert_schema - - -class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The request body which contain contact detail metadata. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :vartype alert_type: str - :ivar email_receivers: The list of email receivers that are part of this action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this action group. - :vartype webhook_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.WebhookReceiver] - :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. - :vartype itsm_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ItsmReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action - group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureAppPushReceiver] - :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :vartype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AutomationRunbookReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.VoiceReceiver] - :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. - :vartype logic_app_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.LogicAppReceiver] - :ivar azure_function_receivers: The list of azure function receivers that are part of this - action group. - :vartype azure_function_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureFunctionReceiver] - :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :vartype arm_role_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ArmRoleReceiver] - :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. - :vartype event_hub_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EventHubReceiver] - """ - - _validation = { - "alert_type": {"required": True, "max_length": 30}, - } - - _attribute_map = { - "alert_type": {"key": "alertType", "type": "str"}, - "email_receivers": {"key": "emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "webhookReceivers", "type": "[WebhookReceiver]"}, - "itsm_receivers": {"key": "itsmReceivers", "type": "[ItsmReceiver]"}, - "azure_app_push_receivers": {"key": "azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "automation_runbook_receivers": {"key": "automationRunbookReceivers", "type": "[AutomationRunbookReceiver]"}, - "voice_receivers": {"key": "voiceReceivers", "type": "[VoiceReceiver]"}, - "logic_app_receivers": {"key": "logicAppReceivers", "type": "[LogicAppReceiver]"}, - "azure_function_receivers": {"key": "azureFunctionReceivers", "type": "[AzureFunctionReceiver]"}, - "arm_role_receivers": {"key": "armRoleReceivers", "type": "[ArmRoleReceiver]"}, - "event_hub_receivers": {"key": "eventHubReceivers", "type": "[EventHubReceiver]"}, - } - - def __init__( - self, - *, - alert_type: str, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword alert_type: The value of the supported alert type. Supported alert type values are: - servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, - webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - actualcostbudget, forecastedbudget. Required. - :paramtype alert_type: str - :keyword email_receivers: The list of email receivers that are part of this action group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this action group. - :paramtype webhook_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.WebhookReceiver] - :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. - :paramtype itsm_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ItsmReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureAppPushReceiver] - :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :paramtype automation_runbook_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AutomationRunbookReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this action group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.VoiceReceiver] - :keyword logic_app_receivers: The list of logic app receivers that are part of this action - group. - :paramtype logic_app_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.LogicAppReceiver] - :keyword azure_function_receivers: The list of azure function receivers that are part of this - action group. - :paramtype azure_function_receivers: - list[~azure.mgmt.monitor.v2023_01_01.models.AzureFunctionReceiver] - :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. - Roles are Azure RBAC roles and only built-in roles are supported. - :paramtype arm_role_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.ArmRoleReceiver] - :keyword event_hub_receivers: The list of event hub receivers that are part of this action - group. - :paramtype event_hub_receivers: list[~azure.mgmt.monitor.v2023_01_01.models.EventHubReceiver] - """ - super().__init__(**kwargs) - self.alert_type = alert_type - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.itsm_receivers = itsm_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.automation_runbook_receivers = automation_runbook_receivers - self.voice_receivers = voice_receivers - self.logic_app_receivers = logic_app_receivers - self.azure_function_receivers = azure_function_receivers - self.arm_role_receivers = arm_role_receivers - self.event_hub_receivers = event_hub_receivers - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2023_01_01.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class TestNotificationDetailsResponse(_serialization.Model): - """The details of the test notification results. - - All required parameters must be populated in order to send to Azure. - - :ivar context: The context info. - :vartype context: ~azure.mgmt.monitor.v2023_01_01.models.Context - :ivar state: The overall state. Required. - :vartype state: str - :ivar completed_time: The completed time. - :vartype completed_time: str - :ivar created_time: The created time. - :vartype created_time: str - :ivar action_details: The list of action detail. - :vartype action_details: list[~azure.mgmt.monitor.v2023_01_01.models.ActionDetail] - """ - - _validation = { - "state": {"required": True}, - } - - _attribute_map = { - "context": {"key": "context", "type": "Context"}, - "state": {"key": "state", "type": "str"}, - "completed_time": {"key": "completedTime", "type": "str"}, - "created_time": {"key": "createdTime", "type": "str"}, - "action_details": {"key": "actionDetails", "type": "[ActionDetail]"}, - } - - def __init__( - self, - *, - state: str, - context: Optional["_models.Context"] = None, - completed_time: Optional[str] = None, - created_time: Optional[str] = None, - action_details: Optional[List["_models.ActionDetail"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context: The context info. - :paramtype context: ~azure.mgmt.monitor.v2023_01_01.models.Context - :keyword state: The overall state. Required. - :paramtype state: str - :keyword completed_time: The completed time. - :paramtype completed_time: str - :keyword created_time: The created time. - :paramtype created_time: str - :keyword action_details: The list of action detail. - :paramtype action_details: list[~azure.mgmt.monitor.v2023_01_01.models.ActionDetail] - """ - super().__init__(**kwargs) - self.context = context - self.state = state - self.completed_time = completed_time - self.created_time = created_time - self.action_details = action_details - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within an - action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - an action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - an action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar use_aad_auth: Indicates whether or not use AAD authentication. - :vartype use_aad_auth: bool - :ivar object_id: Indicates the webhook app object Id for aad auth. - :vartype object_id: str - :ivar identifier_uri: Indicates the identifier uri for aad auth. - :vartype identifier_uri: str - :ivar tenant_id: Indicates the tenant id for aad auth. - :vartype tenant_id: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, - "object_id": {"key": "objectId", "type": "str"}, - "identifier_uri": {"key": "identifierUri", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - service_uri: str, - use_common_alert_schema: bool = False, - use_aad_auth: bool = False, - object_id: Optional[str] = None, - identifier_uri: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within an action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword use_aad_auth: Indicates whether or not use AAD authentication. - :paramtype use_aad_auth: bool - :keyword object_id: Indicates the webhook app object Id for aad auth. - :paramtype object_id: str - :keyword identifier_uri: Indicates the identifier uri for aad auth. - :paramtype identifier_uri: str - :keyword tenant_id: Indicates the tenant id for aad auth. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - self.use_aad_auth = use_aad_auth - self.object_id = object_id - self.identifier_uri = identifier_uri - self.tenant_id = tenant_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_monitor_management_client_enums.py deleted file mode 100644 index 2502d854d1869..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/__init__.py deleted file mode 100644 index 05f0527dc9796..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._action_groups_operations import ActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/_action_groups_operations.py deleted file mode 100644 index 8dc6e1859808e..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/_action_groups_operations.py +++ /dev/null @@ -1,1390 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_test_notifications_at_action_group_resource_level_request( # pylint: disable=name-too-long - resource_group_name: str, action_group_name: str, notification_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_receiver_request( - resource_group_name: str, action_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2023_01_01.MonitorManagementClient`'s - :attr:`action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: _models.ActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - action_group_name: str, - action_group: Union[_models.ActionGroupResource, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Create a new action group or update an existing one. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a - ActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "ActionGroupResource") - - request = build_create_or_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: - """Get an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> None: - """Delete an action group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Required. - :type action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - action_group_name: str, - action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.ActionGroupResource: - """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type action_group_patch: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group_patch, (IO, bytes)): - _content = action_group_patch - else: - _json = self._serialize.body(action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" - } - - def _create_notifications_at_action_group_resource_level_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> Optional[_models.TestNotificationDetailsResponse]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(notification_request, (IO, bytes)): - _content = notification_request - else: - _json = self._serialize.body(notification_request, "NotificationRequestBody") - - request = build_create_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._create_notifications_at_action_group_resource_level_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - _create_notifications_at_action_group_resource_level_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @overload - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: _models.NotificationRequestBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: ~azure.mgmt.monitor.v2023_01_01.models.NotificationRequestBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Required. - :type notification_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, - resource_group_name: str, - action_group_name: str, - notification_request: Union[_models.NotificationRequestBody, IO], - **kwargs: Any - ) -> LROPoller[_models.TestNotificationDetailsResponse]: - """Send test notifications to a set of provided receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_request: The notification request body which includes the contact details. - Is either a NotificationRequestBody type or a IO type. Required. - :type notification_request: ~azure.mgmt.monitor.v2023_01_01.models.NotificationRequestBody or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_notifications_at_action_group_resource_level_initial( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_request=notification_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" - } - - @distributed_trace - def get_test_notifications_at_action_group_resource_level( # pylint: disable=name-too-long - self, resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any - ) -> _models.TestNotificationDetailsResponse: - """Get the test notifications by the notification id. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param notification_id: The notification id. Required. - :type notification_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TestNotificationDetailsResponse or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_01_01.models.TestNotificationDetailsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) - - request = build_get_test_notifications_at_action_group_resource_level_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - notification_id=notification_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_test_notifications_at_action_group_resource_level.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TestNotificationDetailsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_test_notifications_at_action_group_resource_level.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" - } - - @distributed_trace - def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_subscription_id_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_subscription_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_subscription_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" - } - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupResource"]: - """Get a list of all action groups in a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionGroupResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2023_01_01.models.ActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" - } - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: _models.EnableRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: ~azure.mgmt.monitor.v2023_01_01.models.EnableRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Required. - :type enable_request: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def enable_receiver( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - action_group_name: str, - enable_request: Union[_models.EnableRequest, IO], - **kwargs: Any - ) -> None: - """Enable a receiver in an action group. This changes the receiver's status from Disabled to - Enabled. This operation is only supported for Email or SMS receivers. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param action_group_name: The name of the action group. Required. - :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. - Required. - :type enable_request: ~azure.mgmt.monitor.v2023_01_01.models.EnableRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 304: ResourceNotModifiedError, - 409: lambda response: ResourceExistsError(response=response, error_format=ARMErrorFormat), - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(enable_request, (IO, bytes)): - _content = enable_request - else: - _json = self._serialize.body(enable_request, "EnableRequest") - - request = build_enable_receiver_request( - resource_group_name=resource_group_name, - action_group_name=action_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.enable_receiver.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_receiver.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_01_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/__init__.py deleted file mode 100644 index 2c7733bfd5664..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_configuration.py deleted file mode 100644 index 3c8cf235fbbad..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_metadata.json deleted file mode 100644 index 7ff4dcddf356f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_metadata.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "chosen_version": "2023-03-01-preview", - "total_api_version_list": ["2023-03-01-preview"], - "client": { - "name": "MonitorManagementClient", - "filename": "_monitor_management_client", - "description": "Monitor Management Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "tenant_action_groups": "TenantActionGroupsOperations" - } -} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_monitor_management_client.py deleted file mode 100644 index d3b97cc5c89ba..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_monitor_management_client.py +++ /dev/null @@ -1,84 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import TenantActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar tenant_action_groups: TenantActionGroupsOperations operations - :vartype tenant_action_groups: - azure.mgmt.monitor.v2023_03_01_preview.operations.TenantActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.tenant_action_groups = TenantActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "MonitorManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_version.py deleted file mode 100644 index 394ee7c0c03cd..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "6.0.2" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/__init__.py deleted file mode 100644 index 2c151bb41c199..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._monitor_management_client import MonitorManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "MonitorManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_configuration.py deleted file mode 100644 index e95fb3f74ae14..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for MonitorManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_monitor_management_client.py deleted file mode 100644 index 5bafc0c09b2b1..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_monitor_management_client.py +++ /dev/null @@ -1,84 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import MonitorManagementClientConfiguration -from .operations import TenantActionGroupsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Monitor Management Client. - - :ivar tenant_action_groups: TenantActionGroupsOperations operations - :vartype tenant_action_groups: - azure.mgmt.monitor.v2023_03_01_preview.aio.operations.TenantActionGroupsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2023-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.tenant_action_groups = TenantActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "MonitorManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/__init__.py deleted file mode 100644 index 19fc239386816..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._tenant_action_groups_operations import TenantActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "TenantActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/_tenant_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/_tenant_action_groups_operations.py deleted file mode 100644 index dd43cf92c8c6c..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/aio/operations/_tenant_action_groups_operations.py +++ /dev/null @@ -1,588 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._tenant_action_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_management_group_id_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TenantActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2023_03_01_preview.aio.MonitorManagementClient`'s - :attr:`tenant_action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - action_group: _models.TenantActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Create a new tenant action group or update an existing one. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param action_group: The tenant action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Create a new tenant action group or update an existing one. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param action_group: The tenant action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - action_group: Union[_models.TenantActionGroupResource, IO], - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Create a new tenant action group or update an existing one. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param action_group: The tenant action group to create or use for the update. Is either a - TenantActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TenantActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "TenantActionGroupResource") - - request = build_create_or_update_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @distributed_trace_async - async def get( - self, management_group_id: str, tenant_action_group_name: str, x_ms_client_tenant_id: str, **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Get a tenant action group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - cls: ClsType[_models.TenantActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, tenant_action_group_name: str, x_ms_client_tenant_id: str, **kwargs: Any - ) -> None: - """Delete a tenant action group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @overload - async def update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - tenant_action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Updates an existing tenant action group's tags. To update other fields use the CreateOrUpdate - method. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param tenant_action_group_patch: Parameters supplied to the operation. Required. - :type tenant_action_group_patch: - ~azure.mgmt.monitor.v2023_03_01_preview.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - tenant_action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Updates an existing tenant action group's tags. To update other fields use the CreateOrUpdate - method. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param tenant_action_group_patch: Parameters supplied to the operation. Required. - :type tenant_action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - tenant_action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Updates an existing tenant action group's tags. To update other fields use the CreateOrUpdate - method. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param tenant_action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type tenant_action_group_patch: - ~azure.mgmt.monitor.v2023_03_01_preview.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TenantActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(tenant_action_group_patch, (IO, bytes)): - _content = tenant_action_group_patch - else: - _json = self._serialize.body(tenant_action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @distributed_trace - def list_by_management_group_id( - self, management_group_id: str, x_ms_client_tenant_id: str, **kwargs: Any - ) -> AsyncIterable["_models.TenantActionGroupResource"]: - """Get a list of all tenant action groups in a management group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantActionGroupResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - cls: ClsType[_models.TenantActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_management_group_id_request( - management_group_id=management_group_id, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - template_url=self.list_by_management_group_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TenantActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_management_group_id.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/__init__.py deleted file mode 100644 index ff5d331e257fc..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ActionGroupPatchBody -from ._models_py3 import AzureAppPushReceiver -from ._models_py3 import AzureResource -from ._models_py3 import EmailReceiver -from ._models_py3 import ErrorResponse -from ._models_py3 import SmsReceiver -from ._models_py3 import TenantActionGroupList -from ._models_py3 import TenantActionGroupResource -from ._models_py3 import VoiceReceiver -from ._models_py3 import WebhookReceiver - -from ._monitor_management_client_enums import ReceiverStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActionGroupPatchBody", - "AzureAppPushReceiver", - "AzureResource", - "EmailReceiver", - "ErrorResponse", - "SmsReceiver", - "TenantActionGroupList", - "TenantActionGroupResource", - "VoiceReceiver", - "WebhookReceiver", - "ReceiverStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_models_py3.py deleted file mode 100644 index 0228f1dc008ea..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_models_py3.py +++ /dev/null @@ -1,517 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Dict, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActionGroupPatchBody(_serialization.Model): - """A tenant action group object for the body of patch operations. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar enabled: Indicates whether this tenant action group is enabled. If a tenant action group - is not enabled, then none of its actions will be activated. - :vartype enabled: bool - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled: Indicates whether this tenant action group is enabled. If a tenant action - group is not enabled, then none of its actions will be activated. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.enabled = enabled - - -class AzureAppPushReceiver(_serialization.Model): - """The Azure mobile App push notification receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within a tenant action group. Required. - :vartype name: str - :ivar email_address: The email address registered for the Azure mobile app. Required. - :vartype email_address: str - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all - receivers within a tenant action group. Required. - :paramtype name: str - :keyword email_address: The email address registered for the Azure mobile app. Required. - :paramtype email_address: str - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - - -class AzureResource(_serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.tags = tags - - -class EmailReceiver(_serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the email receiver. Names must be unique across all receivers within a - tenant action group. Required. - :vartype name: str - :ivar email_address: The email address of this receiver. Required. - :vartype email_address: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", - and "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2023_03_01_preview.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "email_address": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "email_address": {"key": "emailAddress", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the email receiver. Names must be unique across all receivers within - a tenant action group. Required. - :paramtype name: str - :keyword email_address: The email address of this receiver. Required. - :paramtype email_address: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - """ - super().__init__(**kwargs) - self.name = name - self.email_address = email_address - self.use_common_alert_schema = use_common_alert_schema - self.status = None - - -class ErrorResponse(_serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class SmsReceiver(_serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the SMS receiver. Names must be unique across all receivers within a - tenant action group. Required. - :vartype name: str - :ivar country_code: The country code of the SMS receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the SMS receiver. Required. - :vartype phone_number: str - :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", and - "Disabled". - :vartype status: str or ~azure.mgmt.monitor.v2023_03_01_preview.models.ReceiverStatus - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the SMS receiver. Names must be unique across all receivers within a - tenant action group. Required. - :paramtype name: str - :keyword country_code: The country code of the SMS receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the SMS receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - self.status = None - - -class TenantActionGroupList(_serialization.Model): - """A list of tenant action groups. - - :ivar value: The list of tenant action groups. - :vartype value: list[~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource] - :ivar next_link: Provides the link to retrieve the next set of elements. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[TenantActionGroupResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.TenantActionGroupResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of tenant action groups. - :paramtype value: - list[~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource] - :keyword next_link: Provides the link to retrieve the next set of elements. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class TenantActionGroupResource(AzureResource): # pylint: disable=too-many-instance-attributes - """A tenant action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar group_short_name: The short name of the action group. This will be used in SMS messages. - :vartype group_short_name: str - :ivar enabled: Indicates whether this tenant action group is enabled. If a tenant action group - is not enabled, then none of its receivers will receive communications. - :vartype enabled: bool - :ivar email_receivers: The list of email receivers that are part of this tenant action group. - :vartype email_receivers: list[~azure.mgmt.monitor.v2023_03_01_preview.models.EmailReceiver] - :ivar sms_receivers: The list of SMS receivers that are part of this tenant action group. - :vartype sms_receivers: list[~azure.mgmt.monitor.v2023_03_01_preview.models.SmsReceiver] - :ivar webhook_receivers: The list of webhook receivers that are part of this tenant action - group. - :vartype webhook_receivers: - list[~azure.mgmt.monitor.v2023_03_01_preview.models.WebhookReceiver] - :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this tenant - action group. - :vartype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2023_03_01_preview.models.AzureAppPushReceiver] - :ivar voice_receivers: The list of voice receivers that are part of this tenant action group. - :vartype voice_receivers: list[~azure.mgmt.monitor.v2023_03_01_preview.models.VoiceReceiver] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "group_short_name": {"max_length": 12}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "group_short_name": {"key": "properties.groupShortName", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "email_receivers": {"key": "properties.emailReceivers", "type": "[EmailReceiver]"}, - "sms_receivers": {"key": "properties.smsReceivers", "type": "[SmsReceiver]"}, - "webhook_receivers": {"key": "properties.webhookReceivers", "type": "[WebhookReceiver]"}, - "azure_app_push_receivers": {"key": "properties.azureAppPushReceivers", "type": "[AzureAppPushReceiver]"}, - "voice_receivers": {"key": "properties.voiceReceivers", "type": "[VoiceReceiver]"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - group_short_name: Optional[str] = None, - enabled: bool = True, - email_receivers: Optional[List["_models.EmailReceiver"]] = None, - sms_receivers: Optional[List["_models.SmsReceiver"]] = None, - webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, - azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, - voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword group_short_name: The short name of the action group. This will be used in SMS - messages. - :paramtype group_short_name: str - :keyword enabled: Indicates whether this tenant action group is enabled. If a tenant action - group is not enabled, then none of its receivers will receive communications. - :paramtype enabled: bool - :keyword email_receivers: The list of email receivers that are part of this tenant action - group. - :paramtype email_receivers: list[~azure.mgmt.monitor.v2023_03_01_preview.models.EmailReceiver] - :keyword sms_receivers: The list of SMS receivers that are part of this tenant action group. - :paramtype sms_receivers: list[~azure.mgmt.monitor.v2023_03_01_preview.models.SmsReceiver] - :keyword webhook_receivers: The list of webhook receivers that are part of this tenant action - group. - :paramtype webhook_receivers: - list[~azure.mgmt.monitor.v2023_03_01_preview.models.WebhookReceiver] - :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - tenant action group. - :paramtype azure_app_push_receivers: - list[~azure.mgmt.monitor.v2023_03_01_preview.models.AzureAppPushReceiver] - :keyword voice_receivers: The list of voice receivers that are part of this tenant action - group. - :paramtype voice_receivers: list[~azure.mgmt.monitor.v2023_03_01_preview.models.VoiceReceiver] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.group_short_name = group_short_name - self.enabled = enabled - self.email_receivers = email_receivers - self.sms_receivers = sms_receivers - self.webhook_receivers = webhook_receivers - self.azure_app_push_receivers = azure_app_push_receivers - self.voice_receivers = voice_receivers - - -class VoiceReceiver(_serialization.Model): - """A voice receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the voice receiver. Names must be unique across all receivers within a - tenant action group. Required. - :vartype name: str - :ivar country_code: The country code of the voice receiver. Required. - :vartype country_code: str - :ivar phone_number: The phone number of the voice receiver. Required. - :vartype phone_number: str - """ - - _validation = { - "name": {"required": True}, - "country_code": {"required": True}, - "phone_number": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "country_code": {"key": "countryCode", "type": "str"}, - "phone_number": {"key": "phoneNumber", "type": "str"}, - } - - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the voice receiver. Names must be unique across all receivers within - a tenant action group. Required. - :paramtype name: str - :keyword country_code: The country code of the voice receiver. Required. - :paramtype country_code: str - :keyword phone_number: The phone number of the voice receiver. Required. - :paramtype phone_number: str - """ - super().__init__(**kwargs) - self.name = name - self.country_code = country_code - self.phone_number = phone_number - - -class WebhookReceiver(_serialization.Model): - """A webhook receiver. - - All required parameters must be populated in order to send to Azure. - - :ivar name: The name of the webhook receiver. Names must be unique across all receivers within - a tenant action group. Required. - :vartype name: str - :ivar service_uri: The URI where webhooks should be sent. Required. - :vartype service_uri: str - :ivar use_common_alert_schema: Indicates whether to use common alert schema. - :vartype use_common_alert_schema: bool - :ivar use_aad_auth: Indicates whether or not use AAD authentication. - :vartype use_aad_auth: bool - :ivar object_id: Indicates the webhook app object Id for aad auth. - :vartype object_id: str - :ivar identifier_uri: Indicates the identifier uri for aad auth. - :vartype identifier_uri: str - :ivar tenant_id: Indicates the tenant id for aad auth. - :vartype tenant_id: str - """ - - _validation = { - "name": {"required": True}, - "service_uri": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "service_uri": {"key": "serviceUri", "type": "str"}, - "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, - "use_aad_auth": {"key": "useAadAuth", "type": "bool"}, - "object_id": {"key": "objectId", "type": "str"}, - "identifier_uri": {"key": "identifierUri", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - service_uri: str, - use_common_alert_schema: bool = False, - use_aad_auth: bool = False, - object_id: Optional[str] = None, - identifier_uri: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the webhook receiver. Names must be unique across all receivers - within a tenant action group. Required. - :paramtype name: str - :keyword service_uri: The URI where webhooks should be sent. Required. - :paramtype service_uri: str - :keyword use_common_alert_schema: Indicates whether to use common alert schema. - :paramtype use_common_alert_schema: bool - :keyword use_aad_auth: Indicates whether or not use AAD authentication. - :paramtype use_aad_auth: bool - :keyword object_id: Indicates the webhook app object Id for aad auth. - :paramtype object_id: str - :keyword identifier_uri: Indicates the identifier uri for aad auth. - :paramtype identifier_uri: str - :keyword tenant_id: Indicates the tenant id for aad auth. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.name = name - self.service_uri = service_uri - self.use_common_alert_schema = use_common_alert_schema - self.use_aad_auth = use_aad_auth - self.object_id = object_id - self.identifier_uri = identifier_uri - self.tenant_id = tenant_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_monitor_management_client_enums.py deleted file mode 100644 index 2502d854d1869..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_monitor_management_client_enums.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the status of the receiver. Receivers that are not Enabled will not receive any - communications. - """ - - NOT_SPECIFIED = "NotSpecified" - ENABLED = "Enabled" - DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/__init__.py deleted file mode 100644 index 19fc239386816..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._tenant_action_groups_operations import TenantActionGroupsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "TenantActionGroupsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333d..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/_tenant_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/_tenant_action_groups_operations.py deleted file mode 100644 index f9e38c81b647f..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/operations/_tenant_action_groups_operations.py +++ /dev/null @@ -1,744 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - management_group_id: str, tenant_action_group_name: str, *, x_ms_client_tenant_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "tenantActionGroupName": _SERIALIZER.url("tenant_action_group_name", tenant_action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["x-ms-client-tenant-id"] = _SERIALIZER.header("x_ms_client_tenant_id", x_ms_client_tenant_id, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - management_group_id: str, tenant_action_group_name: str, *, x_ms_client_tenant_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "tenantActionGroupName": _SERIALIZER.url("tenant_action_group_name", tenant_action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["x-ms-client-tenant-id"] = _SERIALIZER.header("x_ms_client_tenant_id", x_ms_client_tenant_id, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - management_group_id: str, tenant_action_group_name: str, *, x_ms_client_tenant_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "tenantActionGroupName": _SERIALIZER.url("tenant_action_group_name", tenant_action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["x-ms-client-tenant-id"] = _SERIALIZER.header("x_ms_client_tenant_id", x_ms_client_tenant_id, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - management_group_id: str, tenant_action_group_name: str, *, x_ms_client_tenant_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "tenantActionGroupName": _SERIALIZER.url("tenant_action_group_name", tenant_action_group_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["x-ms-client-tenant-id"] = _SERIALIZER.header("x_ms_client_tenant_id", x_ms_client_tenant_id, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_management_group_id_request( # pylint: disable=name-too-long - management_group_id: str, *, x_ms_client_tenant_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups", - ) # pylint: disable=line-too-long - path_format_arguments = { - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["x-ms-client-tenant-id"] = _SERIALIZER.header("x_ms_client_tenant_id", x_ms_client_tenant_id, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class TenantActionGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.monitor.v2023_03_01_preview.MonitorManagementClient`'s - :attr:`tenant_action_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - action_group: _models.TenantActionGroupResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Create a new tenant action group or update an existing one. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param action_group: The tenant action group to create or use for the update. Required. - :type action_group: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - action_group: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Create a new tenant action group or update an existing one. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param action_group: The tenant action group to create or use for the update. Required. - :type action_group: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - action_group: Union[_models.TenantActionGroupResource, IO], - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Create a new tenant action group or update an existing one. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param action_group: The tenant action group to create or use for the update. Is either a - TenantActionGroupResource type or a IO type. Required. - :type action_group: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TenantActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(action_group, (IO, bytes)): - _content = action_group - else: - _json = self._serialize.body(action_group, "TenantActionGroupResource") - - request = build_create_or_update_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @distributed_trace - def get( - self, management_group_id: str, tenant_action_group_name: str, x_ms_client_tenant_id: str, **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Get a tenant action group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - cls: ClsType[_models.TenantActionGroupResource] = kwargs.pop("cls", None) - - request = build_get_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, management_group_id: str, tenant_action_group_name: str, x_ms_client_tenant_id: str, **kwargs: Any - ) -> None: - """Delete a tenant action group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @overload - def update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - tenant_action_group_patch: _models.ActionGroupPatchBody, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Updates an existing tenant action group's tags. To update other fields use the CreateOrUpdate - method. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param tenant_action_group_patch: Parameters supplied to the operation. Required. - :type tenant_action_group_patch: - ~azure.mgmt.monitor.v2023_03_01_preview.models.ActionGroupPatchBody - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - tenant_action_group_patch: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Updates an existing tenant action group's tags. To update other fields use the CreateOrUpdate - method. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param tenant_action_group_patch: Parameters supplied to the operation. Required. - :type tenant_action_group_patch: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - management_group_id: str, - tenant_action_group_name: str, - x_ms_client_tenant_id: str, - tenant_action_group_patch: Union[_models.ActionGroupPatchBody, IO], - **kwargs: Any - ) -> _models.TenantActionGroupResource: - """Updates an existing tenant action group's tags. To update other fields use the CreateOrUpdate - method. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param tenant_action_group_name: The name of the action group. Required. - :type tenant_action_group_name: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :param tenant_action_group_patch: Parameters supplied to the operation. Is either a - ActionGroupPatchBody type or a IO type. Required. - :type tenant_action_group_patch: - ~azure.mgmt.monitor.v2023_03_01_preview.models.ActionGroupPatchBody or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TenantActionGroupResource or the result of cls(response) - :rtype: ~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.TenantActionGroupResource] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(tenant_action_group_patch, (IO, bytes)): - _content = tenant_action_group_patch - else: - _json = self._serialize.body(tenant_action_group_patch, "ActionGroupPatchBody") - - request = build_update_request( - management_group_id=management_group_id, - tenant_action_group_name=tenant_action_group_name, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("TenantActionGroupResource", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups/{tenantActionGroupName}" - } - - @distributed_trace - def list_by_management_group_id( - self, management_group_id: str, x_ms_client_tenant_id: str, **kwargs: Any - ) -> Iterable["_models.TenantActionGroupResource"]: - """Get a list of all tenant action groups in a management group. - - :param management_group_id: The management group id. Required. - :type management_group_id: str - :param x_ms_client_tenant_id: The tenant ID of the client making the request. Required. - :type x_ms_client_tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TenantActionGroupResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.monitor.v2023_03_01_preview.models.TenantActionGroupResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) - cls: ClsType[_models.TenantActionGroupList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_management_group_id_request( - management_group_id=management_group_id, - x_ms_client_tenant_id=x_ms_client_tenant_id, - api_version=api_version, - template_url=self.list_by_management_group_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("TenantActionGroupList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_management_group_id.metadata = { - "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/tenantActionGroups" - } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/py.typed deleted file mode 100644 index e5aff4f83af86..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2023_03_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_action_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_action_group.py index 4dd3d512ffb12..5fe194e611c90 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_action_group.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_action_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -123,6 +124,6 @@ def main(): print(response) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/createOrUpdateActionGroup.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/createOrUpdateActionGroup.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_activity_log_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_activity_log_alert.py new file mode 100644 index 0000000000000..de36a187ac94a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_activity_log_alert.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_activity_log_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.activity_log_alerts.create_or_update( + resource_group_name="Default-ActivityLogAlerts", + activity_log_alert_name="SampleActivityLogAlert", + activity_log_alert={ + "location": "Global", + "properties": { + "actions": { + "actionGroups": [ + { + "actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/Default-ActionGroups/providers/microsoft.insights/actionGroups/SampleActionGroup", + "webhookProperties": {"sampleWebhookProperty": "samplePropertyValue"}, + } + ] + }, + "condition": { + "allOf": [{"equals": "Administrative", "field": "Category"}, {"equals": "Error", "field": "Level"}] + }, + "description": "Sample activity log alert description", + "enabled": True, + "scopes": ["subscriptions/187f412d-1758-44d9-b052-169e2564721d"], + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2017-04-01/examples/createOrUpdateActivityLogAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_autoscale_setting.py new file mode 100644 index 0000000000000..15996ea7970f0 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_autoscale_setting.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_autoscale_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.create_or_update( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + parameters={ + "location": "West US", + "properties": { + "enabled": True, + "notifications": [ + { + "email": { + "customEmails": ["gu@ms.com", "ge@ns.net"], + "sendToSubscriptionAdministrator": True, + "sendToSubscriptionCoAdministrators": True, + }, + "operation": "Scale", + "webhooks": [{"properties": {}, "serviceUri": "http://myservice.com"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "Enabled"}, + "profiles": [ + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "fixedDate": { + "end": "2015-03-05T14:30:00Z", + "start": "2015-03-05T14:00:00Z", + "timeZone": "UTC", + }, + "name": "adios", + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "name": "saludos", + "recurrence": { + "frequency": "Week", + "schedule": {"days": ["1"], "hours": [5], "minutes": [15], "timeZone": "UTC"}, + }, + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + ], + "targetResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + }, + "tags": {"key1": "value1", "key2": "value2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/createOrUpdateAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_diagnostic_setting.py new file mode 100644 index 0000000000000..1484f6033e113 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_diagnostic_setting.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings.create_or_update( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + name="mysetting", + parameters={ + "properties": { + "eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule", + "eventHubName": "myeventhub", + "logAnalyticsDestinationType": "Dedicated", + "logs": [ + {"categoryGroup": "allLogs", "enabled": True, "retentionPolicy": {"days": 0, "enabled": False}} + ], + "marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1", + "metrics": [ + {"category": "WorkflowMetrics", "enabled": True, "retentionPolicy": {"days": 0, "enabled": False}} + ], + "storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1", + "workspaceId": "", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/createOrUpdateDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_diagnostic_setting_category.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_diagnostic_setting_category.py new file mode 100644 index 0000000000000..8c683b5e8f1db --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_diagnostic_setting_category.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_diagnostic_setting_category.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings.create_or_update( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + name="mysetting", + parameters={ + "properties": { + "eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule", + "eventHubName": "myeventhub", + "logAnalyticsDestinationType": "Dedicated", + "logs": [ + {"category": "WorkflowRuntime", "enabled": True, "retentionPolicy": {"days": 0, "enabled": False}} + ], + "marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1", + "metrics": [ + {"category": "WorkflowMetrics", "enabled": True, "retentionPolicy": {"days": 0, "enabled": False}} + ], + "storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1", + "workspaceId": "", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/createOrUpdateDiagnosticSettingCategory.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_dynamic_metric_alert_multiple_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_dynamic_metric_alert_multiple_resource.py new file mode 100644 index 0000000000000..f6eaf24252f27 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_dynamic_metric_alert_multiple_resource.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_dynamic_metric_alert_multiple_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="gigtest", + rule_name="MetricAlertOnMultipleResources", + parameters={ + "location": "global", + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "alertSensitivity": "Medium", + "criterionType": "DynamicThresholdCriterion", + "dimensions": [], + "failingPeriods": {"minFailingPeriodsToAlert": 4, "numberOfEvaluationPeriods": 4}, + "metricName": "Percentage CPU", + "metricNamespace": "microsoft.compute/virtualmachines", + "name": "High_CPU_80", + "operator": "GreaterOrLessThan", + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": [ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1", + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2", + ], + "severity": 3, + "targetResourceRegion": "southcentralus", + "targetResourceType": "Microsoft.Compute/virtualMachines", + "windowSize": "PT15M", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateDynamicMetricAlertMultipleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_dynamic_metric_alert_single_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_dynamic_metric_alert_single_resource.py new file mode 100644 index 0000000000000..83c268d41d44a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_dynamic_metric_alert_single_resource.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_dynamic_metric_alert_single_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="gigtest", + rule_name="chiricutin", + parameters={ + "location": "global", + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "alertSensitivity": "Medium", + "criterionType": "DynamicThresholdCriterion", + "dimensions": [], + "failingPeriods": {"minFailingPeriodsToAlert": 4, "numberOfEvaluationPeriods": 4}, + "ignoreDataBefore": "2019-04-04T21:00:00.000Z", + "metricName": "Percentage CPU", + "metricNamespace": "microsoft.compute/virtualmachines", + "name": "High_CPU_80", + "operator": "GreaterOrLessThan", + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": [ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" + ], + "severity": 3, + "windowSize": "PT15M", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateDynamicMetricAlertSingleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_guest_diagnostic_settings.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_guest_diagnostic_settings.py new file mode 100644 index 0000000000000..aeb02e6166c53 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_guest_diagnostic_settings.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_guest_diagnostic_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.guest_diagnostics_settings.create_or_update( + resource_group_name="Default-ResourceGroup", + diagnostic_settings_name="SampleDiagSetting", + diagnostic_settings={ + "location": "Global", + "properties": { + "dataSources": [ + { + "configuration": { + "perfCounters": [ + {"name": "\\Process(_Total)\\%Processor Time", "samplingPeriod": "PT1M"}, + {"name": "\\Process(_Total)\\Working Set", "samplingPeriod": "PT1M"}, + ] + }, + "kind": "PerformanceCounter", + "sinks": [{"kind": "LogAnalytics"}], + }, + { + "configuration": { + "providers": [ + {"filter": "filter exp", "id": 1, "name": "AuditLog"}, + {"id": 2, "name": "TraceLog"}, + ] + }, + "kind": "ETWProviders", + "sinks": [{"kind": "LogAnalytics"}], + }, + { + "configuration": { + "eventLogs": [ + { + "filter": 'SourceName == Xyz AND EventId = "100" AND $Xpath/Column="DCName" = "CatWoman"', + "logName": "Application", + }, + { + "filter": 'SourceName == Xyz AND EventId = "100" AND $Xpath/Column="DCName" = "BatMan"', + "logName": "Application", + }, + ] + }, + "kind": "WindowsEventLogs", + "sinks": [{"kind": "LogAnalytics"}], + }, + ], + "osType": "Windows", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-06-01-preview/examples/createOrUpdateGuestDiagnosticSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_guest_diagnostic_settings_association.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_guest_diagnostic_settings_association.py new file mode 100644 index 0000000000000..2aaeee6173f97 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_guest_diagnostic_settings_association.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_guest_diagnostic_settings_association.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.guest_diagnostics_settings_association.create_or_update( + resource_uri="subscriptions/8498f01b-8064-4e37-856e-318f3c6c685f/resourceGroups/healthsystem/providers/Microsoft.Compute/virtualMachines/eastussojai", + association_name="healthSystemMachineConfigAssociation", + diagnostic_settings_association={ + "location": "Global", + "properties": { + "guestDiagnosticSettingsName": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/Default-Association-ResourceGroup/providers/providers/microsoft.insights/guestDiagnosticSettings/vmSettingForSecurity" + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-06-01-preview/examples/createOrUpdateGuestDiagnosticSettingsAssociation.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_log_profile.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_log_profile.py new file mode 100644 index 0000000000000..8b64fb714b96c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_log_profile.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_log_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="df602c9c-7aa0-407d-a6fb-eb20c8bd1192", + ) + + response = client.log_profiles.create_or_update( + log_profile_name="Rac46PostSwapRG", + parameters={ + "location": "", + "properties": { + "categories": ["Write", "Delete", "Action"], + "locations": ["global"], + "retentionPolicy": {"days": 3, "enabled": True}, + "serviceBusRuleId": "", + "storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/JohnKemTest/providers/Microsoft.Storage/storageAccounts/johnkemtest8162", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/createOrUpdateLogProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_multiple_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_multiple_resource.py new file mode 100644 index 0000000000000..2a39423d15308 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_multiple_resource.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_metric_alert_multiple_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="gigtest", + rule_name="MetricAlertOnMultipleResources", + parameters={ + "location": "global", + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "criterionType": "StaticThresholdCriterion", + "dimensions": [], + "metricName": "Percentage CPU", + "metricNamespace": "microsoft.compute/virtualmachines", + "name": "High_CPU_80", + "operator": "GreaterThan", + "threshold": 80.5, + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": [ + "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1", + "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2", + ], + "severity": 3, + "targetResourceRegion": "southcentralus", + "targetResourceType": "Microsoft.Compute/virtualMachines", + "windowSize": "PT15M", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertMultipleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_resource_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_resource_group.py new file mode 100644 index 0000000000000..321d34bccacd0 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_resource_group.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_metric_alert_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="gigtest1", + rule_name="MetricAlertAtResourceGroupLevel", + parameters={ + "location": "global", + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "criterionType": "StaticThresholdCriterion", + "dimensions": [], + "metricName": "Percentage CPU", + "metricNamespace": "microsoft.compute/virtualmachines", + "name": "High_CPU_80", + "operator": "GreaterThan", + "threshold": 80.5, + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": [ + "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1", + "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2", + ], + "severity": 3, + "targetResourceRegion": "southcentralus", + "targetResourceType": "Microsoft.Compute/virtualMachines", + "windowSize": "PT15M", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_single_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_single_resource.py new file mode 100644 index 0000000000000..1e672eb045f6c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_single_resource.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_metric_alert_single_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="gigtest", + rule_name="chiricutin", + parameters={ + "location": "global", + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "criterionType": "StaticThresholdCriterion", + "dimensions": [], + "metricName": "\\Processor(_Total)\\% Processor Time", + "name": "High_CPU_80", + "operator": "GreaterThan", + "threshold": 80.5, + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": [ + "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" + ], + "severity": 3, + "windowSize": "PT15M", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertSingleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_subscription.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_subscription.py new file mode 100644 index 0000000000000..b22ee9a388d81 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_subscription.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_metric_alert_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="gigtest", + rule_name="MetricAlertAtSubscriptionLevel", + parameters={ + "location": "global", + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "criterionType": "StaticThresholdCriterion", + "dimensions": [], + "metricName": "Percentage CPU", + "metricNamespace": "microsoft.compute/virtualmachines", + "name": "High_CPU_80", + "operator": "GreaterThan", + "threshold": 80.5, + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": ["/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"], + "severity": 3, + "targetResourceRegion": "southcentralus", + "targetResourceType": "Microsoft.Compute/virtualMachines", + "windowSize": "PT15M", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_with_dimensions.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_with_dimensions.py new file mode 100644 index 0000000000000..71810f9082bb7 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_metric_alert_with_dimensions.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_metric_alert_with_dimensions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="gigtest", + rule_name="MetricAlertOnMultipleDimensions", + parameters={ + "location": "global", + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "criterionType": "StaticThresholdCriterion", + "dimensions": [ + {"name": "ActivityName", "operator": "Include", "values": ["*"]}, + {"name": "StatusCode", "operator": "Include", "values": ["200"]}, + ], + "metricName": "Availability", + "metricNamespace": "Microsoft.KeyVault/vaults", + "name": "Metric1", + "operator": "GreaterThan", + "threshold": 55, + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1H", + "scopes": [ + "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource" + ], + "severity": 3, + "windowSize": "P1D", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertWithDimensions.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_rule_log_to_metric_action.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_rule_log_to_metric_action.py new file mode 100644 index 0000000000000..0a7cc5ba6cb03 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_rule_log_to_metric_action.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_scheduled_query_rule_log_to_metric_action.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="af52d502-a447-4bc6-8cb7-4780fbb00490", + ) + + response = client.scheduled_query_rules.create_or_update( + resource_group_name="alertsweu", + rule_name="logtometricfoo", + parameters={ + "location": "West Europe", + "properties": { + "action": { + "criteria": [{"dimensions": [], "metricName": "Average_% Idle Time"}], + "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction", + }, + "description": "log to metric description", + "enabled": "true", + "source": { + "dataSourceId": "/subscriptions/af52d502-a447-4bc6-8cb7-4780fbb00490/resourceGroups/alertsweu/providers/Microsoft.OperationalInsights/workspaces/alertsweu" + }, + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-04-16/examples/createOrUpdateScheduledQueryRule-LogToMetricAction.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_rules.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_rules.py new file mode 100644 index 0000000000000..1a851fe494bf1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_rules.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_scheduled_query_rules.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.scheduled_query_rules.create_or_update( + resource_group_name="Rac46PostSwapRG", + rule_name="logalertfoo", + parameters={ + "location": "eastus", + "properties": { + "action": { + "aznsAction": {"actionGroup": [], "customWebhookPayload": "{}", "emailSubject": "Email Header"}, + "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction", + "severity": "1", + "trigger": { + "metricTrigger": { + "metricColumn": "Computer", + "metricTriggerType": "Consecutive", + "threshold": 5, + "thresholdOperator": "GreaterThan", + }, + "threshold": 3, + "thresholdOperator": "GreaterThan", + }, + }, + "description": "log alert description", + "enabled": "true", + "schedule": {"frequencyInMinutes": 15, "timeWindowInMinutes": 15}, + "source": { + "dataSourceId": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.OperationalInsights/workspaces/sampleWorkspace", + "query": "Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m)", + "queryType": "ResultCount", + }, + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-04-16/examples/createOrUpdateScheduledQueryRules.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_ruleswith_cross_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_ruleswith_cross_resource.py new file mode 100644 index 0000000000000..32e4dd29f8824 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_scheduled_query_ruleswith_cross_resource.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_scheduled_query_ruleswith_cross_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.scheduled_query_rules.create_or_update( + resource_group_name="Rac46PostSwapRG", + rule_name="SampleCrossResourceAlert", + parameters={ + "location": "eastus", + "properties": { + "action": { + "aznsAction": { + "actionGroup": [ + "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/microsoft.insights/actiongroups/test-ag" + ], + "emailSubject": "Cross Resource Mail!!", + }, + "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction", + "severity": "3", + "trigger": {"threshold": 5000, "thresholdOperator": "GreaterThan"}, + }, + "description": "Sample Cross Resource alert", + "enabled": "true", + "schedule": {"frequencyInMinutes": 60, "timeWindowInMinutes": 60}, + "source": { + "authorizedResources": [ + "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.OperationalInsights/workspaces/sampleWorkspace", + "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/microsoft.insights/components/sampleAI", + ], + "dataSourceId": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/microsoft.insights/components/sampleAI", + "query": 'union requests, workspace("sampleWorkspace").Update', + "queryType": "ResultCount", + }, + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-04-16/examples/createOrUpdateScheduledQueryRuleswithCrossResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_service_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_service_diagnostic_setting.py new file mode 100644 index 0000000000000..de1c4127419af --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_service_diagnostic_setting.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_service_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.service_diagnostic_settings.create_or_update( + resource_uri="/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + parameters={ + "location": "", + "properties": { + "eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/eventhubs/myeventhub/authorizationrules/myrule", + "logs": [ + {"category": "WorkflowRuntime", "enabled": True, "retentionPolicy": {"days": 0, "enabled": False}} + ], + "metrics": [{"enabled": True, "retentionPolicy": {"days": 0, "enabled": False}, "timeGrain": "PT1M"}], + "serviceBusRuleId": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/andy1101/providers/Microsoft.EventHub/namespaces/andy1101/authorizationrules/RootManageSharedAccessKey", + "storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1", + "workspaceId": "", + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-09-01/examples/createOrUpdateServiceDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_subscription_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_subscription_diagnostic_setting.py new file mode 100644 index 0000000000000..602269696c92f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_subscription_diagnostic_setting.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_subscription_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="fb9f25f9-5785-4510-a38f-a62f188eb9f8", + ) + + response = client.subscription_diagnostic_settings.create_or_update( + name="ds4", + parameters={ + "properties": { + "eventHubAuthorizationRuleId": "/subscriptions/fb9f25f9-5785-4510-a38f-a62f188eb9f8/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/eventhubs/myeventhub/authorizationrules/myrule", + "eventHubName": "myeventhub", + "logs": [{"category": "Security", "enabled": True}], + "storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1", + "workspaceId": "", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/examples/createOrUpdateSubscriptionDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_web_test_metric_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_web_test_metric_alert.py new file mode 100644 index 0000000000000..f636883a1cda6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/create_or_update_web_test_metric_alert.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_web_test_metric_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789101", + ) + + response = client.metric_alerts.create_or_update( + resource_group_name="rg-example", + rule_name="webtest-name-example", + parameters={ + "location": "global", + "properties": { + "actions": [], + "criteria": { + "componentId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example", + "failedLocationCount": 2, + "odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria", + "webTestId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example", + }, + "description": 'Automatically created alert rule for availability test "component-example" a', + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": [ + "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example", + "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example", + ], + "severity": 4, + "windowSize": "PT15M", + }, + "tags": { + "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example": "Resource", + "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example": "Resource", + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateWebTestMetricAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_action_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_action_group.py index 6716be2d669ff..1c3a53ed9bee5 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_action_group.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_action_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="187f412d-1758-44d9-b052-169e2564721d", ) - response = client.action_groups.delete( + client.action_groups.delete( resource_group_name="Default-NotificationRules", action_group_name="SampleActionGroup", ) - print(response) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/deleteActionGroup.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/deleteActionGroup.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_activity_log_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_activity_log_alert.py new file mode 100644 index 0000000000000..8b771127ec6ba --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_activity_log_alert.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_activity_log_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + client.activity_log_alerts.delete( + resource_group_name="Default-ActivityLogAlerts", + activity_log_alert_name="SampleActivityLogAlert", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2017-04-01/examples/deleteActivityLogAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_autoscale_setting.py new file mode 100644 index 0000000000000..a6149efc8eaef --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_autoscale_setting.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_autoscale_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + client.autoscale_settings.delete( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/deleteAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_diagnostic_setting.py new file mode 100644 index 0000000000000..3c4c9085a2142 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_diagnostic_setting.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.diagnostic_settings.delete( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + name="mysetting", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/deleteDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_guest_diagnostic_settings_association.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_guest_diagnostic_settings_association.py new file mode 100644 index 0000000000000..3345a094fa725 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_guest_diagnostic_settings_association.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_guest_diagnostic_settings_association.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.guest_diagnostics_settings_association.delete( + resource_uri="subscriptions/8498f01b-8064-4e37-856e-318f3c6c685f/resourceGroups/healthsystem/providers/Microsoft.Compute/virtualMachines/eastussojai", + association_name="healthSystemMachineConfigAssociation", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-06-01-preview/examples/deleteGuestDiagnosticSettingsAssociation.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_log_profile.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_log_profile.py new file mode 100644 index 0000000000000..03d4cab69a5c0 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_log_profile.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_log_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + client.log_profiles.delete( + log_profile_name="Rac46PostSwapRG", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/deleteLogProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_metric_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_metric_alert.py new file mode 100644 index 0000000000000..05a38f4462edb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_metric_alert.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_metric_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + client.metric_alerts.delete( + resource_group_name="gigtest", + rule_name="chiricutin", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/deleteMetricAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_scheduled_query_rules.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_scheduled_query_rules.py new file mode 100644 index 0000000000000..5a5d67f2fde6c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_scheduled_query_rules.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_scheduled_query_rules.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + client.scheduled_query_rules.delete( + resource_group_name="Rac46PostSwapRG", + rule_name="logalertfoo", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-04-16/examples/deleteScheduledQueryRules.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_subscription_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_subscription_diagnostic_setting.py new file mode 100644 index 0000000000000..27b6a9a6371fc --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/delete_subscription_diagnostic_setting.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_subscription_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="1a66ce04-b633-4a0b-b2bc-a912ec8986a6", + ) + + client.subscription_diagnostic_settings.delete( + name="ds4", + ) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/examples/deleteSubscriptionDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/enable_receiver.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/enable_receiver.py index 279b1f524c9fc..a044431cdb5e8 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/enable_receiver.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/enable_receiver.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="187f412d-1758-44d9-b052-169e2564721d", ) - response = client.action_groups.enable_receiver( + client.action_groups.enable_receiver( resource_group_name="Default-NotificationRules", action_group_name="SampleActionGroup", enable_request={"receiverName": "John Doe's mobile"}, ) - print(response) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/enableReceiver.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/enableReceiver.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_action_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_action_group.py index 39ea28de7e662..3552f016760b9 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_action_group.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_action_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/getActionGroup.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/getActionGroup.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_log_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_log_alert.py new file mode 100644 index 0000000000000..0662717cdf407 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_log_alert.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_activity_log_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.activity_log_alerts.get( + resource_group_name="Default-ActivityLogAlerts", + activity_log_alert_name="SampleActivityLogAlert", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2017-04-01/examples/getActivityLogAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_logs_filtered.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_logs_filtered.py new file mode 100644 index 0000000000000..30db67fe5e613 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_logs_filtered.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_activity_logs_filtered.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="089bd33f-d4ec-47fe-8ba5-0753aa5c5b33", + ) + + response = client.activity_logs.list( + filter="eventTimestamp ge '2015-01-21T20:00:00Z' and eventTimestamp le '2015-01-23T20:00:00Z' and resourceGroupName eq 'MSSupportGroup'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/GetActivityLogsFiltered.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_logs_filtered_and_selected.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_logs_filtered_and_selected.py new file mode 100644 index 0000000000000..f481ff2ed9135 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_activity_logs_filtered_and_selected.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_activity_logs_filtered_and_selected.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="089bd33f-d4ec-47fe-8ba5-0753aa5c5b33", + ) + + response = client.activity_logs.list( + filter="eventTimestamp ge '2015-01-21T20:00:00Z' and eventTimestamp le '2015-01-23T20:00:00Z' and resourceGroupName eq 'MSSupportGroup'", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/GetActivityLogsFilteredAndSelected.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_alert_rule_incident.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_alert_rule_incident.py new file mode 100644 index 0000000000000..0a1c4c42a2562 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_alert_rule_incident.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_alert_rule_incident.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.alert_rule_incidents.get( + resource_group_name="Rac46PostSwapRG", + rule_name="myRuleName", + incident_name="Website_started", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRuleIncident.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_autoscale_setting.py new file mode 100644 index 0000000000000..a48bc8e4dd6ba --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_autoscale_setting.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_autoscale_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.get( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/getAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_setting.py new file mode 100644 index 0000000000000..c79500db402fd --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_setting.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings.get( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + name="mysetting", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_setting_category.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_setting_category.py new file mode 100644 index 0000000000000..a75b63d3d74d1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_setting_category.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_diagnostic_setting_category.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings.get( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + name="mysetting", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_settings_category.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_settings_category.py new file mode 100644 index 0000000000000..03667b783faa2 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_diagnostic_settings_category.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_diagnostic_settings_category.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings_category.get( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + name="WorkflowRuntime", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/examples/getDiagnosticSettingsCategory.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_dynamic_metric_alert_multiple_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_dynamic_metric_alert_multiple_resource.py new file mode 100644 index 0000000000000..ef81496739595 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_dynamic_metric_alert_multiple_resource.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_dynamic_metric_alert_multiple_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metric_alerts.get( + resource_group_name="gigtest", + rule_name="MetricAlertOnMultipleResources", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertMultipleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_dynamic_metric_alert_single_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_dynamic_metric_alert_single_resource.py new file mode 100644 index 0000000000000..737f6ed33111b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_dynamic_metric_alert_single_resource.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_dynamic_metric_alert_single_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.metric_alerts.get( + resource_group_name="gigtest", + rule_name="chiricutin", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertSingleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_event_categories.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_event_categories.py new file mode 100644 index 0000000000000..ca18b30119fb4 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_event_categories.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_event_categories.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.event_categories.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/GetEventCategories.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_guest_diagnostic_settings_association.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_guest_diagnostic_settings_association.py new file mode 100644 index 0000000000000..b44fd0c2130b1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_guest_diagnostic_settings_association.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_guest_diagnostic_settings_association.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.guest_diagnostics_settings_association.get( + resource_uri="subscriptions/8498f01b-8064-4e37-856e-318f3c6c685f/resourceGroups/healthsystem/providers/Microsoft.Compute/virtualMachines/eastussojai", + association_name="healthSystemMachineConfigAssociation", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-06-01-preview/examples/getGuestDiagnosticSettingsAssociation.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_log_profile.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_log_profile.py new file mode 100644 index 0000000000000..5efa4df692fa6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_log_profile.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_log_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="df602c9c-7aa0-407d-a6fb-eb20c8bd1192", + ) + + response = client.log_profiles.get( + log_profile_name="default", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric.py new file mode 100644 index 0000000000000..7a161d9c275e4 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.metrics.list( + resource_uri="subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/examples/GetMetric.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_multiple_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_multiple_resource.py new file mode 100644 index 0000000000000..361fca95ce14d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_multiple_resource.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_alert_multiple_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.get( + resource_group_name="gigtest", + rule_name="MetricAlertOnMultipleResources", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertMultipleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_resource_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_resource_group.py new file mode 100644 index 0000000000000..8e423c8615cbe --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_alert_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.get( + resource_group_name="gigtest1", + rule_name="MetricAlertAtResourceGroupLevel", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_single_resource.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_single_resource.py new file mode 100644 index 0000000000000..80e094e0df3f5 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_single_resource.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_alert_single_resource.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.get( + resource_group_name="gigtest", + rule_name="chiricutin", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSingleResource.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_status.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_status.py new file mode 100644 index 0000000000000..b46f0bf2896f9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_status.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_alert_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts_status.list( + resource_group_name="gigtest", + rule_name="chiricutin", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_status_by_name.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_status_by_name.py new file mode 100644 index 0000000000000..38182211c6df2 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_status_by_name.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_alert_status_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="009f6022-67ec-423e-9aa7-691182870588", + ) + + response = client.metric_alerts_status.list_by_name( + resource_group_name="EastUs", + rule_name="custom1", + status_name="cmVzb3VyY2VJZD0vc3Vic2NyaXB0aW9ucy8xNGRkZjBjNS03N2M1LTRiNTMtODRmNi1lMWZhNDNhZDY4ZjcvcmVzb3VyY2VHcm91cHMvZ2lndGVzdC9wcm92aWRlcnMvTWljcm9zb2Z0LkNvbXB1dGUvdmlydHVhbE1hY2hpbmVzL2dpZ3dhZG1l", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertStatusByName.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_subscription.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_subscription.py new file mode 100644 index 0000000000000..7dfe8b2c35f3e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_alert_subscription.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_alert_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.get( + resource_group_name="gigtest", + rule_name="MetricAlertAtSubscriptionLevel", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions.py new file mode 100644 index 0000000000000..e5cf555fad827 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_definitions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.metric_definitions.list( + resource_uri="subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/alertruleTest/providers/microsoft.insights/metricDefinitions", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/examples/GetMetricDefinitions.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions_application_insights.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions_application_insights.py new file mode 100644 index 0000000000000..7c69375770090 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions_application_insights.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_definitions_application_insights.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.metric_definitions.list( + resource_uri="subscriptions/182c901a-129a-4f5d-86e4-cc6b294590a2/resourceGroups/hyr-log/providers/microsoft.insights/components/f1-bill/providers/microsoft.insights/metricdefinitions", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/examples/GetMetricDefinitionsApplicationInsights.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions_metric_class.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions_metric_class.py new file mode 100644 index 0000000000000..1cb5422620909 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_definitions_metric_class.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_definitions_metric_class.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.metric_definitions.list( + resource_uri="subscriptions/46841c0e-69c8-4b17-af46-6626ecb15fc2/resourceGroups/adgarntptestrg/providers/Microsoft.StorageCache/caches/adgarntptestcache", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/examples/GetMetricDefinitionsMetricClass.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_error.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_error.py new file mode 100644 index 0000000000000..58a03ac908e4b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_error.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_error.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.metrics.list( + resource_uri="subscriptions/ac41e21f-afd6-4a79-8070-f01eba278f97/resourceGroups/todking/providers/Microsoft.DocumentDb/databaseAccounts/tk-cosmos-mongo", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/examples/GetMetricError.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_metadata.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_metadata.py new file mode 100644 index 0000000000000..e4fe103eeed3f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_metadata.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_metadata.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.metrics.list( + resource_uri="subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/examples/GetMetricMetadata.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_namespaces.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_namespaces.py new file mode 100644 index 0000000000000..f2172a152748b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_metric_namespaces.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_metric_namespaces.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.metric_namespaces.list( + resource_uri="subscriptions/182c901a-129a-4f5d-86e4-cc6b294590a2/resourceGroups/hyr-log/providers/microsoft.insights/components/f1-bill", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/examples/GetMetricNamespaces.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_resource_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_resource_group.py new file mode 100644 index 0000000000000..148af94be14fb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_resource_group.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_onboarding_status_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.vm_insights.get_onboarding_status( + resource_uri="subscriptions/3d51de47-8d1c-4d24-b42f-bcae075dfa87/resourceGroups/resource-group-with-vms", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-11-27-preview/examples/getOnboardingStatusResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_single_vm.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_single_vm.py new file mode 100644 index 0000000000000..803151e85c655 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_single_vm.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_onboarding_status_single_vm.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.vm_insights.get_onboarding_status( + resource_uri="subscriptions/3d51de47-8d1c-4d24-b42f-bcae075dfa87/resourceGroups/vm-resource-group/providers/Microsoft.Compute/virtualMachines/ubuntu-vm", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-11-27-preview/examples/getOnboardingStatusSingleVM.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_single_vm_unknown.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_single_vm_unknown.py new file mode 100644 index 0000000000000..6f27618620369 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_single_vm_unknown.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_onboarding_status_single_vm_unknown.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.vm_insights.get_onboarding_status( + resource_uri="subscriptions/3d51de47-8d1c-4d24-b42f-bcae075dfa87/resourceGroups/vm-resource-group/providers/Microsoft.Compute/virtualMachines/ubuntu-vm", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-11-27-preview/examples/getOnboardingStatusSingleVMUnknown.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_subscription.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_subscription.py new file mode 100644 index 0000000000000..9ddfd67d71995 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_subscription.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_onboarding_status_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.vm_insights.get_onboarding_status( + resource_uri="subscriptions/3d51de47-8d1c-4d24-b42f-bcae075dfa87", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-11-27-preview/examples/getOnboardingStatusSubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_vm_scale_set.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_vm_scale_set.py new file mode 100644 index 0000000000000..e442d0c3f41c6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_onboarding_status_vm_scale_set.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_onboarding_status_vm_scale_set.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.vm_insights.get_onboarding_status( + resource_uri="subscriptions/3d51de47-8d1c-4d24-b42f-bcae075dfa87/resourceGroups/my-service-cluster/providers/Microsoft.Compute/virtualMachineScaleSets/scale-set-01", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-11-27-preview/examples/getOnboardingStatusVMScaleSet.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_predictive_metric.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_predictive_metric.py new file mode 100644 index 0000000000000..a397d0e973a0b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_predictive_metric.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import isodate + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_predictive_metric.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.predictive_metric.get( + resource_group_name="myRG", + autoscale_setting_name="vmss1-Autoscale-775", + timespan="2021-10-14T22:00:00.000Z/2021-10-16T22:00:00.000Z", + interval=isodate.parse_duration("PT1H"), + metric_namespace="Microsoft.Compute/virtualMachineScaleSets", + metric_name="PercentageCPU", + aggregation="Total", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/GetPredictiveMetric.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_scheduled_query_rules.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_scheduled_query_rules.py new file mode 100644 index 0000000000000..e824137614709 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_scheduled_query_rules.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_scheduled_query_rules.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.scheduled_query_rules.get( + resource_group_name="Rac46PostSwapRG", + rule_name="logalertfoo", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-04-16/examples/getScheduledQueryRules.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_service_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_service_diagnostic_setting.py new file mode 100644 index 0000000000000..e3a47061f615d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_service_diagnostic_setting.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_service_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.service_diagnostic_settings.get( + resource_uri="/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-09-01/examples/getServiceDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_subscription_diagnostic_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_subscription_diagnostic_setting.py new file mode 100644 index 0000000000000..7229d2d1d4955 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_subscription_diagnostic_setting.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_subscription_diagnostic_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="fb9f25f9-5785-4510-a38f-a62f188eb9f8", + ) + + response = client.subscription_diagnostic_settings.get( + name="mysetting", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/examples/getSubscriptionDiagnosticSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_filtered.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_filtered.py new file mode 100644 index 0000000000000..3715c67b4930d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_filtered.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_tenant_activity_logs_filtered.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="089bd33f-d4ec-47fe-8ba5-0753aa5c5b33", + ) + + response = client.tenant_activity_logs.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/GetTenantActivityLogsFiltered.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_filtered_and_selected.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_filtered_and_selected.py new file mode 100644 index 0000000000000..a4b1aa57da7d2 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_filtered_and_selected.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_tenant_activity_logs_filtered_and_selected.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="089bd33f-d4ec-47fe-8ba5-0753aa5c5b33", + ) + + response = client.tenant_activity_logs.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/GetTenantActivityLogsFilteredAndSelected.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_no_params.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_no_params.py new file mode 100644 index 0000000000000..155e748e8126f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_no_params.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_tenant_activity_logs_no_params.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="089bd33f-d4ec-47fe-8ba5-0753aa5c5b33", + ) + + response = client.tenant_activity_logs.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/GetTenantActivityLogsNoParams.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_selected.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_selected.py new file mode 100644 index 0000000000000..71e69fce0f688 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_tenant_activity_logs_selected.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_tenant_activity_logs_selected.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="089bd33f-d4ec-47fe-8ba5-0753aa5c5b33", + ) + + response = client.tenant_activity_logs.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/GetTenantActivityLogsSelected.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications.py new file mode 100644 index 0000000000000..9f72676a7730c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_test_notifications.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.action_groups.get_test_notifications( + notification_id="11000222191287", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/getTestNotifications.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications_at_action_group_resource_level.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications_at_action_group_resource_level.py index 639516f78e984..ffd519f62f4be 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications_at_action_group_resource_level.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications_at_action_group_resource_level.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/getTestNotificationsAtActionGroupResourceLevel.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/getTestNotificationsAtActionGroupResourceLevel.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications_at_resource_group_level.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications_at_resource_group_level.py new file mode 100644 index 0000000000000..1661a7cca685e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_test_notifications_at_resource_group_level.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_test_notifications_at_resource_group_level.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.action_groups.get_test_notifications_at_resource_group_level( + resource_group_name="Default-TestNotifications", + notification_id="11000222191287", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/getTestNotificationsAtResourceGroupLevel.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/get_web_test_metric_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_web_test_metric_alert.py new file mode 100644 index 0000000000000..3a2a1978a0481 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/get_web_test_metric_alert.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_web_test_metric_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789101", + ) + + response = client.metric_alerts.get( + resource_group_name="rg-example", + rule_name="webtest-name-example", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getWebTestMetricAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_action_groups.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_action_groups.py index b9a9276dd2eb8..bb03841042969 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_action_groups.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_action_groups.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -29,11 +30,13 @@ def main(): subscription_id="187f412d-1758-44d9-b052-169e2564721d", ) - response = client.action_groups.list_by_subscription_id() + response = client.action_groups.list_by_resource_group( + resource_group_name="Default-NotificationRules", + ) for item in response: print(item) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/listActionGroups.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/listActionGroups.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_activity_log_alerts.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_activity_log_alerts.py new file mode 100644 index 0000000000000..accdd53f5c5cc --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_activity_log_alerts.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_activity_log_alerts.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.activity_log_alerts.list_by_resource_group( + resource_group_name="Default-ActivityLogAlerts", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2017-04-01/examples/listActivityLogAlerts.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_alert_rule_incidents.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_alert_rule_incidents.py new file mode 100644 index 0000000000000..9bc1c28e73d0e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_alert_rule_incidents.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_alert_rule_incidents.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.alert_rule_incidents.list_by_alert_rule( + resource_group_name="Rac46PostSwapRG", + rule_name="myRuleName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listAlertRuleIncidents.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_autoscale_setting.py new file mode 100644 index 0000000000000..4f01aae1b9bcb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_autoscale_setting.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_autoscale_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.list_by_resource_group( + resource_group_name="TestingMetricsScaleSet", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_autoscale_setting_by_subscription.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_autoscale_setting_by_subscription.py new file mode 100644 index 0000000000000..57f152abfa69c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_autoscale_setting_by_subscription.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_autoscale_setting_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSettingBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings.py new file mode 100644 index 0000000000000..72cee34c916bb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_diagnostic_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings.list( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings_categories.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings_categories.py new file mode 100644 index 0000000000000..e3cc502592444 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings_categories.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_diagnostic_settings_categories.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings_category.list( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/examples/listDiagnosticSettingsCategories.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings_category.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings_category.py new file mode 100644 index 0000000000000..5ee0448e874f3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_diagnostic_settings_category.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_diagnostic_settings_category.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.diagnostic_settings.list( + resource_uri="subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettingsCategory.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_log_profile.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_log_profile.py new file mode 100644 index 0000000000000..918d53f6c2498 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_log_profile.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_log_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="df602c9c-7aa0-407d-a6fb-eb20c8bd1192", + ) + + response = client.log_profiles.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listLogProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_metric_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_metric_alert.py new file mode 100644 index 0000000000000..7b86d8f21b692 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_metric_alert.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_metric_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.list_by_resource_group( + resource_group_name="gigtest", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/listMetricAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_scheduled_query_rules.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_scheduled_query_rules.py new file mode 100644 index 0000000000000..5b0cda029648c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_scheduled_query_rules.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_scheduled_query_rules.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.scheduled_query_rules.list_by_resource_group( + resource_group_name="gigtest", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-04-16/examples/listScheduledQueryRules.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/list_subscription_diagnostic_settings.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_subscription_diagnostic_settings.py new file mode 100644 index 0000000000000..e99fda90c43d9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/list_subscription_diagnostic_settings.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_subscription_diagnostic_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="fb9f25f9-5785-4510-a38f-a62f188eb9f8", + ) + + response = client.subscription_diagnostic_settings.list() + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/examples/listSubscriptionDiagnosticSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/metric_baselines.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/metric_baselines.py new file mode 100644 index 0000000000000..0d0d23f92614a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/metric_baselines.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python metric_baselines.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.baselines.list( + resource_uri="subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2019-03-01/examples/metricBaselines.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/operation_list.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/operation_list.py new file mode 100644 index 0000000000000..a3b6b066d8c18 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/operation_list.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python operation_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/examples/OperationList.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_action_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_action_group.py index ab33a88347fe8..a33358e56d15d 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_action_group.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_action_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/patchActionGroup.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/patchActionGroup.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_activity_log_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_activity_log_alert.py new file mode 100644 index 0000000000000..0b23789a0ed0f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_activity_log_alert.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python patch_activity_log_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.activity_log_alerts.update( + resource_group_name="Default-ActivityLogAlerts", + activity_log_alert_name="SampleActivityLogAlert", + activity_log_alert_patch={"properties": {"enabled": False}, "tags": {"key1": "value1", "key2": "value2"}}, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2017-04-01/examples/patchActivityLogAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_autoscale_setting.py new file mode 100644 index 0000000000000..8e093d4eb272f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_autoscale_setting.py @@ -0,0 +1,160 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python patch_autoscale_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.update( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + autoscale_setting_resource={ + "properties": { + "enabled": True, + "notifications": [ + { + "email": { + "customEmails": ["gu@ms.com", "ge@ns.net"], + "sendToSubscriptionAdministrator": True, + "sendToSubscriptionCoAdministrators": True, + }, + "operation": "Scale", + "webhooks": [{"properties": {}, "serviceUri": "http://myservice.com"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "Enabled"}, + "profiles": [ + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "fixedDate": { + "end": "2015-03-05T14:30:00Z", + "start": "2015-03-05T14:00:00Z", + "timeZone": "UTC", + }, + "name": "adios", + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "name": "saludos", + "recurrence": { + "frequency": "Week", + "schedule": {"days": ["1"], "hours": [5], "minutes": [15], "timeZone": "UTC"}, + }, + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + ], + "targetResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + }, + "tags": {"key1": "value1"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/patchAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_log_profile.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_log_profile.py new file mode 100644 index 0000000000000..04b77024f9379 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_log_profile.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python patch_log_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="df602c9c-7aa0-407d-a6fb-eb20c8bd1192", + ) + + response = client.log_profiles.update( + log_profile_name="Rac46PostSwapRG", + log_profiles_resource={ + "properties": { + "categories": ["Write", "Delete", "Action"], + "locations": ["global"], + "retentionPolicy": {"days": 3, "enabled": True}, + "serviceBusRuleId": "", + "storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/JohnKemTest/providers/Microsoft.Storage/storageAccounts/johnkemtest8162", + }, + "tags": {"key1": "value1"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/patchLogProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_scheduled_query_rules.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_scheduled_query_rules.py new file mode 100644 index 0000000000000..b9456f3ffd1bb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/patch_scheduled_query_rules.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python patch_scheduled_query_rules.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.scheduled_query_rules.update( + resource_group_name="my-resource-group", + rule_name="logalertfoo", + parameters={"properties": {"enabled": "true"}}, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-04-16/examples/patchScheduledQueryRules.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications.py new file mode 100644 index 0000000000000..6374ae07f2aee --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python post_test_notifications.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.action_groups.begin_post_test_notifications( + notification_request={ + "alertType": "budget", + "armRoleReceivers": [ + { + "name": "ArmRole-Common", + "roleId": "11111111-1111-1111-1111-111111111111", + "useCommonAlertSchema": True, + }, + { + "name": "ArmRole-nonCommon", + "roleId": "11111111-1111-1111-1111-111111111111", + "useCommonAlertSchema": False, + }, + ], + "automationRunbookReceivers": [ + { + "automationAccountId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest", + "isGlobalRunbook": False, + "name": "testRunbook", + "runbookName": "Sample runbook", + "serviceUri": "http://test.me", + "useCommonAlertSchema": True, + "webhookResourceId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084", + } + ], + "azureAppPushReceivers": [{"emailAddress": "johndoe@email.com", "name": "Sample azureAppPush"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp", + "functionName": "HttpTriggerCSharp1", + "httpTriggerUrl": "http://test.me", + "name": "Sample azureFunction", + "useCommonAlertSchema": True, + } + ], + "emailReceivers": [ + {"emailAddress": "johndoe@email.com", "name": "John Doe's email", "useCommonAlertSchema": False}, + {"emailAddress": "janesmith@email.com", "name": "Jane Smith's email", "useCommonAlertSchema": True}, + ], + "eventHubReceivers": [ + { + "eventHubName": "testEventHub", + "eventHubNameSpace": "testEventHubNameSpace", + "name": "Sample eventHub", + "subscriptionId": "187f412d-1758-44d9-b052-169e2564721d", + "tenantId": "68a4459a-ccb8-493c-b9da-dd30457d1b84", + } + ], + "itsmReceivers": [ + { + "connectionId": "a3b9076c-ce8e-434e-85b4-aff10cb3c8f1", + "name": "Sample itsm", + "region": "westcentralus", + "ticketConfiguration": '{"PayloadRevision":0,"WorkItemType":"Incident","UseTemplate":false,"WorkItemData":"{}","CreateOneWIPerCI":false}', + "workspaceId": "5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c", + } + ], + "logicAppReceivers": [ + { + "callbackUrl": "https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w", + "name": "Sample logicApp", + "resourceId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp", + "useCommonAlertSchema": False, + } + ], + "smsReceivers": [ + {"countryCode": "1", "name": "John Doe's mobile", "phoneNumber": "1234567890"}, + {"countryCode": "1", "name": "Jane Smith's mobile", "phoneNumber": "0987654321"}, + ], + "voiceReceivers": [{"countryCode": "1", "name": "Sample voice", "phoneNumber": "1234567890"}], + "webhookReceivers": [ + { + "name": "Sample webhook 1", + "serviceUri": "http://www.example.com/webhook1", + "useCommonAlertSchema": True, + }, + { + "identifierUri": "http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a", + "name": "Sample webhook 2", + "objectId": "d3bb868c-fe44-452c-aa26-769a6538c808", + "serviceUri": "http://www.example.com/webhook2", + "tenantId": "68a4459a-ccb8-493c-b9da-dd30457d1b84", + "useAadAuth": True, + "useCommonAlertSchema": True, + }, + ], + }, + ).result() + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/postTestNotifications.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications_at_action_group_resource_level.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications_at_action_group_resource_level.py index 1653ae8ce3cc2..dd3e23cee1e21 100644 --- a/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications_at_action_group_resource_level.py +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications_at_action_group_resource_level.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.monitor import MonitorManagementClient """ @@ -123,6 +124,6 @@ def main(): print(response) -# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/postTestNotificationsAtActionGroupResourceLevel.json +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/postTestNotificationsAtActionGroupResourceLevel.json if __name__ == "__main__": main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications_at_resource_group_level.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications_at_resource_group_level.py new file mode 100644 index 0000000000000..a5ed720e80b21 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/post_test_notifications_at_resource_group_level.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python post_test_notifications_at_resource_group_level.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="187f412d-1758-44d9-b052-169e2564721d", + ) + + response = client.action_groups.begin_create_notifications_at_resource_group_level( + resource_group_name="Default-TestNotifications", + notification_request={ + "alertType": "budget", + "armRoleReceivers": [ + { + "name": "ArmRole-Common", + "roleId": "11111111-1111-1111-1111-111111111111", + "useCommonAlertSchema": True, + }, + { + "name": "ArmRole-nonCommon", + "roleId": "11111111-1111-1111-1111-111111111111", + "useCommonAlertSchema": False, + }, + ], + "automationRunbookReceivers": [ + { + "automationAccountId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest", + "isGlobalRunbook": False, + "name": "testRunbook", + "runbookName": "Sample runbook", + "serviceUri": "http://test.me", + "useCommonAlertSchema": True, + "webhookResourceId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084", + } + ], + "azureAppPushReceivers": [{"emailAddress": "johndoe@email.com", "name": "Sample azureAppPush"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp", + "functionName": "HttpTriggerCSharp1", + "httpTriggerUrl": "http://test.me", + "name": "Sample azureFunction", + "useCommonAlertSchema": True, + } + ], + "emailReceivers": [ + {"emailAddress": "johndoe@email.com", "name": "John Doe's email", "useCommonAlertSchema": False}, + {"emailAddress": "janesmith@email.com", "name": "Jane Smith's email", "useCommonAlertSchema": True}, + ], + "eventHubReceivers": [ + { + "eventHubName": "testEventHub", + "eventHubNameSpace": "testEventHubNameSpace", + "name": "Sample eventHub", + "subscriptionId": "187f412d-1758-44d9-b052-169e2564721d", + "tenantId": "68a4459a-ccb8-493c-b9da-dd30457d1b84", + } + ], + "itsmReceivers": [ + { + "connectionId": "a3b9076c-ce8e-434e-85b4-aff10cb3c8f1", + "name": "Sample itsm", + "region": "westcentralus", + "ticketConfiguration": '{"PayloadRevision":0,"WorkItemType":"Incident","UseTemplate":false,"WorkItemData":"{}","CreateOneWIPerCI":false}', + "workspaceId": "5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c", + } + ], + "logicAppReceivers": [ + { + "callbackUrl": "https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w", + "name": "Sample logicApp", + "resourceId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp", + "useCommonAlertSchema": False, + } + ], + "smsReceivers": [ + {"countryCode": "1", "name": "John Doe's mobile", "phoneNumber": "1234567890"}, + {"countryCode": "1", "name": "Jane Smith's mobile", "phoneNumber": "0987654321"}, + ], + "voiceReceivers": [{"countryCode": "1", "name": "Sample voice", "phoneNumber": "1234567890"}], + "webhookReceivers": [ + { + "name": "Sample webhook 1", + "serviceUri": "http://www.example.com/webhook1", + "useCommonAlertSchema": True, + }, + { + "identifierUri": "http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a", + "name": "Sample webhook 2", + "objectId": "d3bb868c-fe44-452c-aa26-769a6538c808", + "serviceUri": "http://www.example.com/webhook2", + "tenantId": "68a4459a-ccb8-493c-b9da-dd30457d1b84", + "useAadAuth": True, + "useCommonAlertSchema": True, + }, + ], + }, + ).result() + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/postTestNotificationsAtResourceGroupLevel.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_delete.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_delete.py new file mode 100644 index 0000000000000..bbfd18b37747f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_endpoint_connection_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + client.private_endpoint_connections.begin_delete( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + private_endpoint_connection_name="private-endpoint-connection-name", + ).result() + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateEndpointConnectionDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_get.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_get.py new file mode 100644 index 0000000000000..5bc28d0ed411f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_endpoint_connection_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_endpoint_connections.get( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + private_endpoint_connection_name="private-endpoint-connection-name", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateEndpointConnectionGet.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_list.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_list.py new file mode 100644 index 0000000000000..3c5df23a790b9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_endpoint_connection_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_endpoint_connections.list_by_private_link_scope( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateEndpointConnectionList.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_update.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_update.py new file mode 100644 index 0000000000000..4d7270430865d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_endpoint_connection_update.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_endpoint_connection_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_endpoint_connections.begin_create_or_update( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + private_endpoint_connection_name="private-endpoint-connection-name", + parameters={ + "properties": { + "privateLinkServiceConnectionState": { + "description": "Approved by johndoe@contoso.com", + "status": "Approved", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateEndpointConnectionUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_operation_statuses.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_operation_statuses.py new file mode 100644 index 0000000000000..f6af3a58eaff3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_operation_statuses.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scope_operation_statuses.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="613192d7-503f-477a-9cfe-4efc3ee2bd60", + ) + + response = client.private_link_scope_operation_status.get( + async_operation_id="713192d7-503f-477a-9cfe-4efc3ee2bd11", + resource_group_name="MyResourceGroup", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/privateLinkScopeOperationStatuses.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_private_link_resource_get.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_private_link_resource_get.py new file mode 100644 index 0000000000000..dae06377a0dc6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_private_link_resource_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scope_private_link_resource_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_link_resources.get( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + group_name="azuremonitor", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopePrivateLinkResourceGet.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_private_link_resource_list_get.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_private_link_resource_list_get.py new file mode 100644 index 0000000000000..2e04d2dcbce6e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scope_private_link_resource_list_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scope_private_link_resource_list_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_link_resources.list_by_private_link_scope( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopePrivateLinkResourceListGet.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_delete.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_delete.py new file mode 100644 index 0000000000000..0fc6e30219988 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scoped_resource_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + client.private_link_scoped_resources.begin_delete( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + name="scoped-resource-name", + ).result() + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopedResourceDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_get.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_get.py new file mode 100644 index 0000000000000..74d8a9c938878 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scoped_resource_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_link_scoped_resources.get( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + name="scoped-resource-name", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopedResourceGet.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_list.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_list.py new file mode 100644 index 0000000000000..8cade548c4083 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scoped_resource_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_link_scoped_resources.list_by_private_link_scope( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopedResourceList.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_update.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_update.py new file mode 100644 index 0000000000000..da967cd54e428 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scoped_resource_update.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scoped_resource_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.private_link_scoped_resources.begin_create_or_update( + resource_group_name="MyResourceGroup", + scope_name="MyPrivateLinkScope", + name="scoped-resource-name", + parameters={ + "properties": { + "linkedResourceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/components/my-component" + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopedResourceUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_delete.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_delete.py new file mode 100644 index 0000000000000..df372e18c1acf --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scopes_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="86dc51d3-92ed-4d7e-947a-775ea79b4919", + ) + + client.private_link_scopes.begin_delete( + resource_group_name="my-resource-group", + scope_name="my-privatelinkscope", + ).result() + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopesDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_get.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_get.py new file mode 100644 index 0000000000000..8f157d9c44b32 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scopes_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="86dc51d3-92ed-4d7e-947a-775ea79b4919", + ) + + response = client.private_link_scopes.get( + resource_group_name="my-resource-group", + scope_name="my-privatelinkscope", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopesGet.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_list.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_list.py new file mode 100644 index 0000000000000..525b277cc1dd6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_list.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scopes_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="86dc51d3-92ed-4d7e-947a-775ea79b4919", + ) + + response = client.private_link_scopes.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopesList.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_list_by_resource_group.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_list_by_resource_group.py new file mode 100644 index 0000000000000..93ab2115fdc28 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/private_link_scopes_list_by_resource_group.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python private_link_scopes_list_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="86dc51d3-92ed-4d7e-947a-775ea79b4919", + ) + + response = client.private_link_scopes.list_by_resource_group( + resource_group_name="my-resource-group", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/examples/PrivateLinkScopesListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/update_guest_diagnostic_settings_association.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/update_guest_diagnostic_settings_association.py new file mode 100644 index 0000000000000..0825cc09fbda9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/update_guest_diagnostic_settings_association.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python update_guest_diagnostic_settings_association.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.guest_diagnostics_settings_association.update( + resource_uri="subscriptions/8498f01b-8064-4e37-856e-318f3c6c685f/resourceGroups/healthsystem/providers/Microsoft.Compute/virtualMachines/eastussojai", + association_name="healthSystemMachineConfigAssociation", + parameters={ + "properties": { + "guestDiagnosticSettingsName": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/Default-Association-ResourceGroup/providers/providers/microsoft.insights/guestDiagnosticSettings/vmSettingForSecurity" + }, + "tags": None, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2018-06-01-preview/examples/updateGuestDiagnosticSettingsAssociation.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_samples/update_metric_alert.py b/sdk/monitor/azure-mgmt-monitor/generated_samples/update_metric_alert.py new file mode 100644 index 0000000000000..9f41fc188390c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_samples/update_metric_alert.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python update_metric_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", + ) + + response = client.metric_alerts.update( + resource_group_name="gigtest", + rule_name="chiricutin", + parameters={ + "properties": { + "actions": [ + { + "actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2", + "webHookProperties": {"key11": "value11", "key12": "value12"}, + } + ], + "autoMitigate": True, + "criteria": { + "allOf": [ + { + "criterionType": "StaticThresholdCriterion", + "dimensions": [], + "metricName": "\\Processor(_Total)\\% Processor Time", + "name": "High_CPU_80", + "operator": "GreaterThan", + "threshold": 80.5, + "timeAggregation": "Average", + } + ], + "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + }, + "description": "This is the description of the rule1", + "enabled": True, + "evaluationFrequency": "PT1M", + "scopes": [ + "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" + ], + "severity": 3, + "windowSize": "PT15M", + }, + "tags": {}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/UpdateMetricAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/conftest.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/conftest.py new file mode 100644 index 0000000000000..f4702001bc6cd --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + monitormanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + monitormanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + monitormanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + monitormanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_action_groups_operations.py new file mode 100644 index 0000000000000..027e937ff2a84 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_action_groups_operations.py @@ -0,0 +1,429 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementActionGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_create_or_update(self, resource_group): + response = self.client.action_groups.create_or_update( + resource_group_name=resource_group.name, + action_group_name="str", + action_group={ + "location": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "enabled": True, + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "groupShortName": "str", + "id": "str", + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "name": "str", + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "tags": {"str": "str"}, + "type": "str", + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_get(self, resource_group): + response = self.client.action_groups.get( + resource_group_name=resource_group.name, + action_group_name="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_delete(self, resource_group): + response = self.client.action_groups.delete( + resource_group_name=resource_group.name, + action_group_name="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_update(self, resource_group): + response = self.client.action_groups.update( + resource_group_name=resource_group.name, + action_group_name="str", + action_group_patch={"enabled": True, "tags": {"str": "str"}}, + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_begin_post_test_notifications(self, resource_group): + response = self.client.action_groups.begin_post_test_notifications( + notification_request={ + "alertType": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_begin_create_notifications_at_resource_group_level(self, resource_group): + response = self.client.action_groups.begin_create_notifications_at_resource_group_level( + resource_group_name=resource_group.name, + notification_request={ + "alertType": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_begin_create_notifications_at_action_group_resource_level(self, resource_group): + response = self.client.action_groups.begin_create_notifications_at_action_group_resource_level( + resource_group_name=resource_group.name, + action_group_name="str", + notification_request={ + "alertType": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_get_test_notifications(self, resource_group): + response = self.client.action_groups.get_test_notifications( + notification_id="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_get_test_notifications_at_resource_group_level(self, resource_group): + response = self.client.action_groups.get_test_notifications_at_resource_group_level( + resource_group_name=resource_group.name, + notification_id="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_get_test_notifications_at_action_group_resource_level(self, resource_group): + response = self.client.action_groups.get_test_notifications_at_action_group_resource_level( + resource_group_name=resource_group.name, + action_group_name="str", + notification_id="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_list_by_subscription_id(self, resource_group): + response = self.client.action_groups.list_by_subscription_id( + api_version="2022-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_list_by_resource_group(self, resource_group): + response = self.client.action_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_enable_receiver(self, resource_group): + response = self.client.action_groups.enable_receiver( + resource_group_name=resource_group.name, + action_group_name="str", + enable_request={"receiverName": "str"}, + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_action_groups_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_action_groups_operations_async.py new file mode 100644 index 0000000000000..cd9fa1d744577 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_action_groups_operations_async.py @@ -0,0 +1,436 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementActionGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_create_or_update(self, resource_group): + response = await self.client.action_groups.create_or_update( + resource_group_name=resource_group.name, + action_group_name="str", + action_group={ + "location": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "enabled": True, + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "groupShortName": "str", + "id": "str", + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "name": "str", + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "tags": {"str": "str"}, + "type": "str", + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_get(self, resource_group): + response = await self.client.action_groups.get( + resource_group_name=resource_group.name, + action_group_name="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_delete(self, resource_group): + response = await self.client.action_groups.delete( + resource_group_name=resource_group.name, + action_group_name="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_update(self, resource_group): + response = await self.client.action_groups.update( + resource_group_name=resource_group.name, + action_group_name="str", + action_group_patch={"enabled": True, "tags": {"str": "str"}}, + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_begin_post_test_notifications(self, resource_group): + response = await ( + await self.client.action_groups.begin_post_test_notifications( + notification_request={ + "alertType": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_begin_create_notifications_at_resource_group_level(self, resource_group): + response = await ( + await self.client.action_groups.begin_create_notifications_at_resource_group_level( + resource_group_name=resource_group.name, + notification_request={ + "alertType": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_begin_create_notifications_at_action_group_resource_level(self, resource_group): + response = await ( + await self.client.action_groups.begin_create_notifications_at_action_group_resource_level( + resource_group_name=resource_group.name, + action_group_name="str", + notification_request={ + "alertType": "str", + "armRoleReceivers": [{"name": "str", "roleId": "str", "useCommonAlertSchema": False}], + "automationRunbookReceivers": [ + { + "automationAccountId": "str", + "isGlobalRunbook": bool, + "runbookName": "str", + "webhookResourceId": "str", + "name": "str", + "serviceUri": "str", + "useCommonAlertSchema": False, + } + ], + "azureAppPushReceivers": [{"emailAddress": "str", "name": "str"}], + "azureFunctionReceivers": [ + { + "functionAppResourceId": "str", + "functionName": "str", + "httpTriggerUrl": "str", + "name": "str", + "useCommonAlertSchema": False, + } + ], + "emailReceivers": [ + {"emailAddress": "str", "name": "str", "status": "str", "useCommonAlertSchema": False} + ], + "eventHubReceivers": [ + { + "eventHubName": "str", + "eventHubNameSpace": "str", + "name": "str", + "subscriptionId": "str", + "tenantId": "str", + "useCommonAlertSchema": False, + } + ], + "itsmReceivers": [ + { + "connectionId": "str", + "name": "str", + "region": "str", + "ticketConfiguration": "str", + "workspaceId": "str", + } + ], + "logicAppReceivers": [ + {"callbackUrl": "str", "name": "str", "resourceId": "str", "useCommonAlertSchema": False} + ], + "smsReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str", "status": "str"}], + "voiceReceivers": [{"countryCode": "str", "name": "str", "phoneNumber": "str"}], + "webhookReceivers": [ + { + "name": "str", + "serviceUri": "str", + "identifierUri": "str", + "objectId": "str", + "tenantId": "str", + "useAadAuth": False, + "useCommonAlertSchema": False, + } + ], + }, + api_version="2022-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_get_test_notifications(self, resource_group): + response = await self.client.action_groups.get_test_notifications( + notification_id="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_get_test_notifications_at_resource_group_level(self, resource_group): + response = await self.client.action_groups.get_test_notifications_at_resource_group_level( + resource_group_name=resource_group.name, + notification_id="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_get_test_notifications_at_action_group_resource_level(self, resource_group): + response = await self.client.action_groups.get_test_notifications_at_action_group_resource_level( + resource_group_name=resource_group.name, + action_group_name="str", + notification_id="str", + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_list_by_subscription_id(self, resource_group): + response = self.client.action_groups.list_by_subscription_id( + api_version="2022-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_list_by_resource_group(self, resource_group): + response = self.client.action_groups.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_enable_receiver(self, resource_group): + response = await self.client.action_groups.enable_receiver( + resource_group_name=resource_group.name, + action_group_name="str", + enable_request={"receiverName": "str"}, + api_version="2022-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_log_alerts_operations.py new file mode 100644 index 0000000000000..310598d7c98c9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_log_alerts_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementActivityLogAlertsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_create_or_update(self, resource_group): + response = self.client.activity_log_alerts.create_or_update( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + activity_log_alert={ + "location": "str", + "actions": {"actionGroups": [{"actionGroupId": "str", "webhookProperties": {"str": "str"}}]}, + "condition": {"allOf": [{"equals": "str", "field": "str"}]}, + "description": "str", + "enabled": True, + "id": "str", + "name": "str", + "scopes": ["str"], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_get(self, resource_group): + response = self.client.activity_log_alerts.get( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_delete(self, resource_group): + response = self.client.activity_log_alerts.delete( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_update(self, resource_group): + response = self.client.activity_log_alerts.update( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + activity_log_alert_patch={"enabled": True, "tags": {"str": "str"}}, + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_list_by_subscription_id(self, resource_group): + response = self.client.activity_log_alerts.list_by_subscription_id( + api_version="2017-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_list_by_resource_group(self, resource_group): + response = self.client.activity_log_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2017-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_log_alerts_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_log_alerts_operations_async.py new file mode 100644 index 0000000000000..63b7a7c70437d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_log_alerts_operations_async.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementActivityLogAlertsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_create_or_update(self, resource_group): + response = await self.client.activity_log_alerts.create_or_update( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + activity_log_alert={ + "location": "str", + "actions": {"actionGroups": [{"actionGroupId": "str", "webhookProperties": {"str": "str"}}]}, + "condition": {"allOf": [{"equals": "str", "field": "str"}]}, + "description": "str", + "enabled": True, + "id": "str", + "name": "str", + "scopes": ["str"], + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_get(self, resource_group): + response = await self.client.activity_log_alerts.get( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_delete(self, resource_group): + response = await self.client.activity_log_alerts.delete( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_update(self, resource_group): + response = await self.client.activity_log_alerts.update( + resource_group_name=resource_group.name, + activity_log_alert_name="str", + activity_log_alert_patch={"enabled": True, "tags": {"str": "str"}}, + api_version="2017-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_list_by_subscription_id(self, resource_group): + response = self.client.activity_log_alerts.list_by_subscription_id( + api_version="2017-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_list_by_resource_group(self, resource_group): + response = self.client.activity_log_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2017-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_logs_operations.py new file mode 100644 index 0000000000000..e494aaae7fafc --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_logs_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementActivityLogsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_logs_list(self, resource_group): + response = self.client.activity_logs.list( + filter="str", + api_version="2015-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_logs_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_logs_operations_async.py new file mode 100644 index 0000000000000..03d872b77d5b9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_activity_logs_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementActivityLogsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_logs_list(self, resource_group): + response = self.client.activity_logs.list( + filter="str", + api_version="2015-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_alert_rule_incidents_operations.py new file mode 100644 index 0000000000000..77474a284f711 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_alert_rule_incidents_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementAlertRuleIncidentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_rule_incidents_get(self, resource_group): + response = self.client.alert_rule_incidents.get( + resource_group_name=resource_group.name, + rule_name="str", + incident_name="str", + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_rule_incidents_list_by_alert_rule(self, resource_group): + response = self.client.alert_rule_incidents.list_by_alert_rule( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2016-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_alert_rule_incidents_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_alert_rule_incidents_operations_async.py new file mode 100644 index 0000000000000..3595db0b33e6b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_alert_rule_incidents_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementAlertRuleIncidentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_rule_incidents_get(self, resource_group): + response = await self.client.alert_rule_incidents.get( + resource_group_name=resource_group.name, + rule_name="str", + incident_name="str", + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_rule_incidents_list_by_alert_rule(self, resource_group): + response = self.client.alert_rule_incidents.list_by_alert_rule( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2016-03-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_autoscale_settings_operations.py new file mode 100644 index 0000000000000..cdfa617c31fa4 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_autoscale_settings_operations.py @@ -0,0 +1,207 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementAutoscaleSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_list_by_resource_group(self, resource_group): + response = self.client.autoscale_settings.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_create_or_update(self, resource_group): + response = self.client.autoscale_settings.create_or_update( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + parameters={ + "location": "str", + "profiles": [ + { + "capacity": {"default": "str", "maximum": "str", "minimum": "str"}, + "name": "str", + "rules": [ + { + "metricTrigger": { + "metricName": "str", + "metricResourceUri": "str", + "operator": "str", + "statistic": "str", + "threshold": 0.0, + "timeAggregation": "str", + "timeGrain": "1 day, 0:00:00", + "timeWindow": "1 day, 0:00:00", + "dimensions": [{"DimensionName": "str", "Operator": "str", "Values": ["str"]}], + "dividePerInstance": bool, + "metricNamespace": "str", + "metricResourceLocation": "str", + }, + "scaleAction": { + "cooldown": "1 day, 0:00:00", + "direction": "str", + "type": "str", + "value": "1", + }, + } + ], + "fixedDate": {"end": "2020-02-20 00:00:00", "start": "2020-02-20 00:00:00", "timeZone": "str"}, + "recurrence": { + "frequency": "str", + "schedule": {"days": ["str"], "hours": [0], "minutes": [0], "timeZone": "str"}, + }, + } + ], + "enabled": False, + "id": "str", + "name": "str", + "notifications": [ + { + "operation": "Scale", + "email": { + "customEmails": ["str"], + "sendToSubscriptionAdministrator": False, + "sendToSubscriptionCoAdministrators": False, + }, + "webhooks": [{"properties": {"str": "str"}, "serviceUri": "str"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "str", "scaleLookAheadTime": "1 day, 0:00:00"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "targetResourceLocation": "str", + "targetResourceUri": "str", + "type": "str", + }, + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_delete(self, resource_group): + response = self.client.autoscale_settings.delete( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_get(self, resource_group): + response = self.client.autoscale_settings.get( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_update(self, resource_group): + response = self.client.autoscale_settings.update( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + autoscale_setting_resource={ + "enabled": False, + "name": "str", + "notifications": [ + { + "operation": "Scale", + "email": { + "customEmails": ["str"], + "sendToSubscriptionAdministrator": False, + "sendToSubscriptionCoAdministrators": False, + }, + "webhooks": [{"properties": {"str": "str"}, "serviceUri": "str"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "str", "scaleLookAheadTime": "1 day, 0:00:00"}, + "profiles": [ + { + "capacity": {"default": "str", "maximum": "str", "minimum": "str"}, + "name": "str", + "rules": [ + { + "metricTrigger": { + "metricName": "str", + "metricResourceUri": "str", + "operator": "str", + "statistic": "str", + "threshold": 0.0, + "timeAggregation": "str", + "timeGrain": "1 day, 0:00:00", + "timeWindow": "1 day, 0:00:00", + "dimensions": [{"DimensionName": "str", "Operator": "str", "Values": ["str"]}], + "dividePerInstance": bool, + "metricNamespace": "str", + "metricResourceLocation": "str", + }, + "scaleAction": { + "cooldown": "1 day, 0:00:00", + "direction": "str", + "type": "str", + "value": "1", + }, + } + ], + "fixedDate": {"end": "2020-02-20 00:00:00", "start": "2020-02-20 00:00:00", "timeZone": "str"}, + "recurrence": { + "frequency": "str", + "schedule": {"days": ["str"], "hours": [0], "minutes": [0], "timeZone": "str"}, + }, + } + ], + "tags": {"str": "str"}, + "targetResourceLocation": "str", + "targetResourceUri": "str", + }, + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_list_by_subscription(self, resource_group): + response = self.client.autoscale_settings.list_by_subscription( + api_version="2022-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_autoscale_settings_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_autoscale_settings_operations_async.py new file mode 100644 index 0000000000000..28ed9f6ec3bec --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_autoscale_settings_operations_async.py @@ -0,0 +1,208 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementAutoscaleSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_list_by_resource_group(self, resource_group): + response = self.client.autoscale_settings.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2022-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_create_or_update(self, resource_group): + response = await self.client.autoscale_settings.create_or_update( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + parameters={ + "location": "str", + "profiles": [ + { + "capacity": {"default": "str", "maximum": "str", "minimum": "str"}, + "name": "str", + "rules": [ + { + "metricTrigger": { + "metricName": "str", + "metricResourceUri": "str", + "operator": "str", + "statistic": "str", + "threshold": 0.0, + "timeAggregation": "str", + "timeGrain": "1 day, 0:00:00", + "timeWindow": "1 day, 0:00:00", + "dimensions": [{"DimensionName": "str", "Operator": "str", "Values": ["str"]}], + "dividePerInstance": bool, + "metricNamespace": "str", + "metricResourceLocation": "str", + }, + "scaleAction": { + "cooldown": "1 day, 0:00:00", + "direction": "str", + "type": "str", + "value": "1", + }, + } + ], + "fixedDate": {"end": "2020-02-20 00:00:00", "start": "2020-02-20 00:00:00", "timeZone": "str"}, + "recurrence": { + "frequency": "str", + "schedule": {"days": ["str"], "hours": [0], "minutes": [0], "timeZone": "str"}, + }, + } + ], + "enabled": False, + "id": "str", + "name": "str", + "notifications": [ + { + "operation": "Scale", + "email": { + "customEmails": ["str"], + "sendToSubscriptionAdministrator": False, + "sendToSubscriptionCoAdministrators": False, + }, + "webhooks": [{"properties": {"str": "str"}, "serviceUri": "str"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "str", "scaleLookAheadTime": "1 day, 0:00:00"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "targetResourceLocation": "str", + "targetResourceUri": "str", + "type": "str", + }, + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_delete(self, resource_group): + response = await self.client.autoscale_settings.delete( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_get(self, resource_group): + response = await self.client.autoscale_settings.get( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_update(self, resource_group): + response = await self.client.autoscale_settings.update( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + autoscale_setting_resource={ + "enabled": False, + "name": "str", + "notifications": [ + { + "operation": "Scale", + "email": { + "customEmails": ["str"], + "sendToSubscriptionAdministrator": False, + "sendToSubscriptionCoAdministrators": False, + }, + "webhooks": [{"properties": {"str": "str"}, "serviceUri": "str"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "str", "scaleLookAheadTime": "1 day, 0:00:00"}, + "profiles": [ + { + "capacity": {"default": "str", "maximum": "str", "minimum": "str"}, + "name": "str", + "rules": [ + { + "metricTrigger": { + "metricName": "str", + "metricResourceUri": "str", + "operator": "str", + "statistic": "str", + "threshold": 0.0, + "timeAggregation": "str", + "timeGrain": "1 day, 0:00:00", + "timeWindow": "1 day, 0:00:00", + "dimensions": [{"DimensionName": "str", "Operator": "str", "Values": ["str"]}], + "dividePerInstance": bool, + "metricNamespace": "str", + "metricResourceLocation": "str", + }, + "scaleAction": { + "cooldown": "1 day, 0:00:00", + "direction": "str", + "type": "str", + "value": "1", + }, + } + ], + "fixedDate": {"end": "2020-02-20 00:00:00", "start": "2020-02-20 00:00:00", "timeZone": "str"}, + "recurrence": { + "frequency": "str", + "schedule": {"days": ["str"], "hours": [0], "minutes": [0], "timeZone": "str"}, + }, + } + ], + "tags": {"str": "str"}, + "targetResourceLocation": "str", + "targetResourceUri": "str", + }, + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_list_by_subscription(self, resource_group): + response = self.client.autoscale_settings.list_by_subscription( + api_version="2022-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_baselines_operations.py new file mode 100644 index 0000000000000..db21cd6027f3a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_baselines_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementBaselinesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_baselines_list(self, resource_group): + response = self.client.baselines.list( + resource_uri="str", + api_version="2019-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_baselines_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_baselines_operations_async.py new file mode 100644 index 0000000000000..e2bb475e34be5 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_baselines_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementBaselinesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_baselines_list(self, resource_group): + response = self.client.baselines.list( + resource_uri="str", + api_version="2019-03-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_category_operations.py new file mode 100644 index 0000000000000..75ead649d6a71 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_category_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementDiagnosticSettingsCategoryOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_diagnostic_settings_category_get(self, resource_group): + response = self.client.diagnostic_settings_category.get( + resource_uri="str", + name="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_diagnostic_settings_category_list(self, resource_group): + response = self.client.diagnostic_settings_category.list( + resource_uri="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_category_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_category_operations_async.py new file mode 100644 index 0000000000000..79e1544528f8f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_category_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementDiagnosticSettingsCategoryOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_diagnostic_settings_category_get(self, resource_group): + response = await self.client.diagnostic_settings_category.get( + resource_uri="str", + name="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_diagnostic_settings_category_list(self, resource_group): + response = await self.client.diagnostic_settings_category.list( + resource_uri="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..a85a9f0cf0e13 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_operations.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementDiagnosticSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_diagnostic_settings_get(self, resource_group): + response = self.client.diagnostic_settings.get( + resource_uri="str", + name="str", + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_diagnostic_settings_create_or_update(self, resource_group): + response = self.client.diagnostic_settings.create_or_update( + resource_uri="str", + name="str", + parameters={ + "eventHubAuthorizationRuleId": "str", + "eventHubName": "str", + "id": "str", + "logAnalyticsDestinationType": "str", + "logs": [ + { + "enabled": bool, + "category": "str", + "categoryGroup": "str", + "retentionPolicy": {"days": 0, "enabled": bool}, + } + ], + "marketplacePartnerId": "str", + "metrics": [ + { + "enabled": bool, + "category": "str", + "retentionPolicy": {"days": 0, "enabled": bool}, + "timeGrain": "1 day, 0:00:00", + } + ], + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "workspaceId": "str", + }, + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_diagnostic_settings_delete(self, resource_group): + response = self.client.diagnostic_settings.delete( + resource_uri="str", + name="str", + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_diagnostic_settings_list(self, resource_group): + response = self.client.diagnostic_settings.list( + resource_uri="str", + api_version="2021-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_operations_async.py new file mode 100644 index 0000000000000..ceb6bd720913c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_diagnostic_settings_operations_async.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementDiagnosticSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_diagnostic_settings_get(self, resource_group): + response = await self.client.diagnostic_settings.get( + resource_uri="str", + name="str", + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_diagnostic_settings_create_or_update(self, resource_group): + response = await self.client.diagnostic_settings.create_or_update( + resource_uri="str", + name="str", + parameters={ + "eventHubAuthorizationRuleId": "str", + "eventHubName": "str", + "id": "str", + "logAnalyticsDestinationType": "str", + "logs": [ + { + "enabled": bool, + "category": "str", + "categoryGroup": "str", + "retentionPolicy": {"days": 0, "enabled": bool}, + } + ], + "marketplacePartnerId": "str", + "metrics": [ + { + "enabled": bool, + "category": "str", + "retentionPolicy": {"days": 0, "enabled": bool}, + "timeGrain": "1 day, 0:00:00", + } + ], + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "workspaceId": "str", + }, + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_diagnostic_settings_delete(self, resource_group): + response = await self.client.diagnostic_settings.delete( + resource_uri="str", + name="str", + api_version="2021-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_diagnostic_settings_list(self, resource_group): + response = self.client.diagnostic_settings.list( + resource_uri="str", + api_version="2021-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_event_categories_operations.py new file mode 100644 index 0000000000000..b9b0820c2f97e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_event_categories_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementEventCategoriesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_event_categories_list(self, resource_group): + response = self.client.event_categories.list( + api_version="2015-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_event_categories_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_event_categories_operations_async.py new file mode 100644 index 0000000000000..310b695b90ce0 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_event_categories_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementEventCategoriesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_event_categories_list(self, resource_group): + response = self.client.event_categories.list( + api_version="2015-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_association_operations.py new file mode 100644 index 0000000000000..7ade293a9e2f6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_association_operations.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementGuestDiagnosticsSettingsAssociationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_create_or_update(self, resource_group): + response = self.client.guest_diagnostics_settings_association.create_or_update( + resource_uri="str", + association_name="str", + diagnostic_settings_association={ + "guestDiagnosticSettingsName": "str", + "location": "str", + "id": "str", + "name": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_get(self, resource_group): + response = self.client.guest_diagnostics_settings_association.get( + resource_uri="str", + association_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_delete(self, resource_group): + response = self.client.guest_diagnostics_settings_association.delete( + resource_uri="str", + association_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_update(self, resource_group): + response = self.client.guest_diagnostics_settings_association.update( + resource_uri="str", + association_name="str", + parameters={"guestDiagnosticSettingsName": "str", "tags": {"str": "str"}}, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_list(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list( + api_version="2018-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_association_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_association_operations_async.py new file mode 100644 index 0000000000000..4ab46cc303c11 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_association_operations_async.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementGuestDiagnosticsSettingsAssociationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_create_or_update(self, resource_group): + response = await self.client.guest_diagnostics_settings_association.create_or_update( + resource_uri="str", + association_name="str", + diagnostic_settings_association={ + "guestDiagnosticSettingsName": "str", + "location": "str", + "id": "str", + "name": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_get(self, resource_group): + response = await self.client.guest_diagnostics_settings_association.get( + resource_uri="str", + association_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_delete(self, resource_group): + response = await self.client.guest_diagnostics_settings_association.delete( + resource_uri="str", + association_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_update(self, resource_group): + response = await self.client.guest_diagnostics_settings_association.update( + resource_uri="str", + association_name="str", + parameters={"guestDiagnosticSettingsName": "str", "tags": {"str": "str"}}, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_list(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list( + api_version="2018-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_operations.py new file mode 100644 index 0000000000000..360fad5da1d0c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_operations.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementGuestDiagnosticsSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_create_or_update(self, resource_group): + response = self.client.guest_diagnostics_settings.create_or_update( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + diagnostic_settings={ + "location": "str", + "dataSources": [ + { + "configuration": { + "eventLogs": [{"logName": "str", "filter": "str"}], + "perfCounters": [{"name": "str", "samplingPeriod": "str", "instance": "str"}], + "providers": [{"events": [{"id": 0, "name": "str", "filter": "str"}], "id": "str"}], + }, + "kind": "str", + "sinks": [{"kind": "str"}], + } + ], + "id": "str", + "name": "str", + "osType": "str", + "proxySetting": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_get(self, resource_group): + response = self.client.guest_diagnostics_settings.get( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_update(self, resource_group): + response = self.client.guest_diagnostics_settings.update( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + parameters={ + "dataSources": [ + { + "configuration": { + "eventLogs": [{"logName": "str", "filter": "str"}], + "perfCounters": [{"name": "str", "samplingPeriod": "str", "instance": "str"}], + "providers": [{"events": [{"id": 0, "name": "str", "filter": "str"}], "id": "str"}], + }, + "kind": "str", + "sinks": [{"kind": "str"}], + } + ], + "osType": "str", + "proxySetting": "str", + "tags": {"str": "str"}, + }, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_delete(self, resource_group): + response = self.client.guest_diagnostics_settings.delete( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_list(self, resource_group): + response = self.client.guest_diagnostics_settings.list( + api_version="2018-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_operations_async.py new file mode 100644 index 0000000000000..7aa81f48cf9ac --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_guest_diagnostics_settings_operations_async.py @@ -0,0 +1,125 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementGuestDiagnosticsSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_create_or_update(self, resource_group): + response = await self.client.guest_diagnostics_settings.create_or_update( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + diagnostic_settings={ + "location": "str", + "dataSources": [ + { + "configuration": { + "eventLogs": [{"logName": "str", "filter": "str"}], + "perfCounters": [{"name": "str", "samplingPeriod": "str", "instance": "str"}], + "providers": [{"events": [{"id": 0, "name": "str", "filter": "str"}], "id": "str"}], + }, + "kind": "str", + "sinks": [{"kind": "str"}], + } + ], + "id": "str", + "name": "str", + "osType": "str", + "proxySetting": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_get(self, resource_group): + response = await self.client.guest_diagnostics_settings.get( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_update(self, resource_group): + response = await self.client.guest_diagnostics_settings.update( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + parameters={ + "dataSources": [ + { + "configuration": { + "eventLogs": [{"logName": "str", "filter": "str"}], + "perfCounters": [{"name": "str", "samplingPeriod": "str", "instance": "str"}], + "providers": [{"events": [{"id": 0, "name": "str", "filter": "str"}], "id": "str"}], + }, + "kind": "str", + "sinks": [{"kind": "str"}], + } + ], + "osType": "str", + "proxySetting": "str", + "tags": {"str": "str"}, + }, + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_delete(self, resource_group): + response = await self.client.guest_diagnostics_settings.delete( + resource_group_name=resource_group.name, + diagnostic_settings_name="str", + api_version="2018-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_list(self, resource_group): + response = self.client.guest_diagnostics_settings.list( + api_version="2018-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_log_profiles_operations.py new file mode 100644 index 0000000000000..7c1fa57d49be0 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_log_profiles_operations.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementLogProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_profiles_delete(self, resource_group): + response = self.client.log_profiles.delete( + log_profile_name="str", + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_profiles_get(self, resource_group): + response = self.client.log_profiles.get( + log_profile_name="str", + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_profiles_create_or_update(self, resource_group): + response = self.client.log_profiles.create_or_update( + log_profile_name="str", + parameters={ + "categories": ["str"], + "location": "str", + "locations": ["str"], + "retentionPolicy": {"days": 0, "enabled": bool}, + "id": "str", + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_profiles_update(self, resource_group): + response = self.client.log_profiles.update( + log_profile_name="str", + log_profiles_resource={ + "categories": ["str"], + "locations": ["str"], + "retentionPolicy": {"days": 0, "enabled": bool}, + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + }, + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_profiles_list(self, resource_group): + response = self.client.log_profiles.list( + api_version="2016-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_log_profiles_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_log_profiles_operations_async.py new file mode 100644 index 0000000000000..8e32c7c01df18 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_log_profiles_operations_async.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementLogProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_profiles_delete(self, resource_group): + response = await self.client.log_profiles.delete( + log_profile_name="str", + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_profiles_get(self, resource_group): + response = await self.client.log_profiles.get( + log_profile_name="str", + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_profiles_create_or_update(self, resource_group): + response = await self.client.log_profiles.create_or_update( + log_profile_name="str", + parameters={ + "categories": ["str"], + "location": "str", + "locations": ["str"], + "retentionPolicy": {"days": 0, "enabled": bool}, + "id": "str", + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_profiles_update(self, resource_group): + response = await self.client.log_profiles.update( + log_profile_name="str", + log_profiles_resource={ + "categories": ["str"], + "locations": ["str"], + "retentionPolicy": {"days": 0, "enabled": bool}, + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + }, + api_version="2016-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_profiles_list(self, resource_group): + response = self.client.log_profiles.list( + api_version="2016-03-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_operations.py new file mode 100644 index 0000000000000..de291b7df7ae2 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_operations.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricAlertsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_list_by_subscription(self, resource_group): + response = self.client.metric_alerts.list_by_subscription( + api_version="2018-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_list_by_resource_group(self, resource_group): + response = self.client.metric_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-03-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_get(self, resource_group): + response = self.client.metric_alerts.get( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_create_or_update(self, resource_group): + response = self.client.metric_alerts.create_or_update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={ + "criteria": "metric_alert_criteria", + "enabled": bool, + "evaluationFrequency": "1 day, 0:00:00", + "location": "str", + "scopes": ["str"], + "severity": 0, + "windowSize": "1 day, 0:00:00", + "actions": [{"actionGroupId": "str", "webHookProperties": {"str": "str"}}], + "autoMitigate": bool, + "description": "str", + "id": "str", + "isMigrated": bool, + "lastUpdatedTime": "2020-02-20 00:00:00", + "name": "str", + "tags": {"str": "str"}, + "targetResourceRegion": "str", + "targetResourceType": "str", + "type": "str", + }, + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_update(self, resource_group): + response = self.client.metric_alerts.update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={ + "actions": [{"actionGroupId": "str", "webHookProperties": {"str": "str"}}], + "autoMitigate": bool, + "criteria": "metric_alert_criteria", + "description": "str", + "enabled": bool, + "evaluationFrequency": "1 day, 0:00:00", + "isMigrated": bool, + "lastUpdatedTime": "2020-02-20 00:00:00", + "scopes": ["str"], + "severity": 0, + "tags": {"str": "str"}, + "targetResourceRegion": "str", + "targetResourceType": "str", + "windowSize": "1 day, 0:00:00", + }, + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_delete(self, resource_group): + response = self.client.metric_alerts.delete( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_operations_async.py new file mode 100644 index 0000000000000..e0f957e1041fd --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_operations_async.py @@ -0,0 +1,125 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricAlertsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_list_by_subscription(self, resource_group): + response = self.client.metric_alerts.list_by_subscription( + api_version="2018-03-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_list_by_resource_group(self, resource_group): + response = self.client.metric_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-03-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_get(self, resource_group): + response = await self.client.metric_alerts.get( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_create_or_update(self, resource_group): + response = await self.client.metric_alerts.create_or_update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={ + "criteria": "metric_alert_criteria", + "enabled": bool, + "evaluationFrequency": "1 day, 0:00:00", + "location": "str", + "scopes": ["str"], + "severity": 0, + "windowSize": "1 day, 0:00:00", + "actions": [{"actionGroupId": "str", "webHookProperties": {"str": "str"}}], + "autoMitigate": bool, + "description": "str", + "id": "str", + "isMigrated": bool, + "lastUpdatedTime": "2020-02-20 00:00:00", + "name": "str", + "tags": {"str": "str"}, + "targetResourceRegion": "str", + "targetResourceType": "str", + "type": "str", + }, + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_update(self, resource_group): + response = await self.client.metric_alerts.update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={ + "actions": [{"actionGroupId": "str", "webHookProperties": {"str": "str"}}], + "autoMitigate": bool, + "criteria": "metric_alert_criteria", + "description": "str", + "enabled": bool, + "evaluationFrequency": "1 day, 0:00:00", + "isMigrated": bool, + "lastUpdatedTime": "2020-02-20 00:00:00", + "scopes": ["str"], + "severity": 0, + "tags": {"str": "str"}, + "targetResourceRegion": "str", + "targetResourceType": "str", + "windowSize": "1 day, 0:00:00", + }, + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_delete(self, resource_group): + response = await self.client.metric_alerts.delete( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_status_operations.py new file mode 100644 index 0000000000000..f78f4b27cce26 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_status_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricAlertsStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_status_list(self, resource_group): + response = self.client.metric_alerts_status.list( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_status_list_by_name(self, resource_group): + response = self.client.metric_alerts_status.list_by_name( + resource_group_name=resource_group.name, + rule_name="str", + status_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_status_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_status_operations_async.py new file mode 100644 index 0000000000000..8a50034e0af99 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_alerts_status_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricAlertsStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_status_list(self, resource_group): + response = await self.client.metric_alerts_status.list( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_status_list_by_name(self, resource_group): + response = await self.client.metric_alerts_status.list_by_name( + resource_group_name=resource_group.name, + rule_name="str", + status_name="str", + api_version="2018-03-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_definitions_operations.py new file mode 100644 index 0000000000000..f737835665069 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_definitions_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_definitions_list(self, resource_group): + response = self.client.metric_definitions.list( + resource_uri="str", + api_version="2018-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_definitions_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_definitions_operations_async.py new file mode 100644 index 0000000000000..ff377c68e2c9d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_definitions_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_definitions_list(self, resource_group): + response = self.client.metric_definitions.list( + resource_uri="str", + api_version="2018-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_namespaces_operations.py new file mode 100644 index 0000000000000..b14504ef48010 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_namespaces_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricNamespacesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_namespaces_list(self, resource_group): + response = self.client.metric_namespaces.list( + resource_uri="str", + api_version="2017-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_namespaces_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_namespaces_operations_async.py new file mode 100644 index 0000000000000..06a79a2b15b80 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metric_namespaces_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricNamespacesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_namespaces_list(self, resource_group): + response = self.client.metric_namespaces.list( + resource_uri="str", + api_version="2017-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metrics_operations.py new file mode 100644 index 0000000000000..7ae33c67fdab9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metrics_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metrics_list(self, resource_group): + response = self.client.metrics.list( + resource_uri="str", + api_version="2018-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metrics_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metrics_operations_async.py new file mode 100644 index 0000000000000..453e3386fff5d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_metrics_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementMetricsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metrics_list(self, resource_group): + response = await self.client.metrics.list( + resource_uri="str", + api_version="2018-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_operations.py new file mode 100644 index 0000000000000..1c34d8a88767f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2015-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_operations_async.py new file mode 100644 index 0000000000000..6f6b529ecec20 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = await self.client.operations.list( + api_version="2015-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_predictive_metric_operations.py new file mode 100644 index 0000000000000..a8f91611e34d0 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_predictive_metric_operations.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPredictiveMetricOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_predictive_metric_get(self, resource_group): + response = self.client.predictive_metric.get( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + timespan="str", + interval="1 day, 0:00:00", + metric_namespace="str", + metric_name="str", + aggregation="str", + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_predictive_metric_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_predictive_metric_operations_async.py new file mode 100644 index 0000000000000..65ff15ea8093b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_predictive_metric_operations_async.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPredictiveMetricOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_predictive_metric_get(self, resource_group): + response = await self.client.predictive_metric.get( + resource_group_name=resource_group.name, + autoscale_setting_name="str", + timespan="str", + interval="1 day, 0:00:00", + metric_namespace="str", + metric_name="str", + aggregation="str", + api_version="2022-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_endpoint_connections_operations.py new file mode 100644 index 0000000000000..4639cff8e8f47 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_endpoint_connections_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + scope_name="str", + private_endpoint_connection_name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_create_or_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + scope_name="str", + private_endpoint_connection_name="str", + parameters={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"description": "str", "status": "str", "actionsRequired": "str"}, + "provisioningState": "str", + "type": "str", + }, + api_version="2019-10-17-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + scope_name="str", + private_endpoint_connection_name="str", + api_version="2019-10-17-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_list_by_private_link_scope(self, resource_group): + response = self.client.private_endpoint_connections.list_by_private_link_scope( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_endpoint_connections_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_endpoint_connections_operations_async.py new file mode 100644 index 0000000000000..2adbd509ee570 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_endpoint_connections_operations_async.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + scope_name="str", + private_endpoint_connection_name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + scope_name="str", + private_endpoint_connection_name="str", + parameters={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + "type": "str", + }, + api_version="2019-10-17-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + scope_name="str", + private_endpoint_connection_name="str", + api_version="2019-10-17-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list_by_private_link_scope(self, resource_group): + response = self.client.private_endpoint_connections.list_by_private_link_scope( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_resources_operations.py new file mode 100644 index 0000000000000..d8c100246ddca --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_resources_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_list_by_private_link_scope(self, resource_group): + response = self.client.private_link_resources.list_by_private_link_scope( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + scope_name="str", + group_name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_resources_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_resources_operations_async.py new file mode 100644 index 0000000000000..933444f017e39 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_resources_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_list_by_private_link_scope(self, resource_group): + response = self.client.private_link_resources.list_by_private_link_scope( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + scope_name="str", + group_name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scope_operation_status_operations.py new file mode 100644 index 0000000000000..22c51ec518d51 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scope_operation_status_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkScopeOperationStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scope_operation_status_get(self, resource_group): + response = self.client.private_link_scope_operation_status.get( + async_operation_id="str", + resource_group_name=resource_group.name, + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scope_operation_status_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scope_operation_status_operations_async.py new file mode 100644 index 0000000000000..95e05e4bbe88e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scope_operation_status_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkScopeOperationStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scope_operation_status_get(self, resource_group): + response = await self.client.private_link_scope_operation_status.get( + async_operation_id="str", + resource_group_name=resource_group.name, + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scoped_resources_operations.py new file mode 100644 index 0000000000000..714967b1bb1fa --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scoped_resources_operations.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkScopedResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scoped_resources_get(self, resource_group): + response = self.client.private_link_scoped_resources.get( + resource_group_name=resource_group.name, + scope_name="str", + name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scoped_resources_begin_create_or_update(self, resource_group): + response = self.client.private_link_scoped_resources.begin_create_or_update( + resource_group_name=resource_group.name, + scope_name="str", + name="str", + parameters={ + "id": "str", + "linkedResourceId": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + }, + api_version="2019-10-17-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scoped_resources_begin_delete(self, resource_group): + response = self.client.private_link_scoped_resources.begin_delete( + resource_group_name=resource_group.name, + scope_name="str", + name="str", + api_version="2019-10-17-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scoped_resources_list_by_private_link_scope(self, resource_group): + response = self.client.private_link_scoped_resources.list_by_private_link_scope( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scoped_resources_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scoped_resources_operations_async.py new file mode 100644 index 0000000000000..b5fdc2ead95c9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scoped_resources_operations_async.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkScopedResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scoped_resources_get(self, resource_group): + response = await self.client.private_link_scoped_resources.get( + resource_group_name=resource_group.name, + scope_name="str", + name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scoped_resources_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_link_scoped_resources.begin_create_or_update( + resource_group_name=resource_group.name, + scope_name="str", + name="str", + parameters={ + "id": "str", + "linkedResourceId": "str", + "name": "str", + "provisioningState": "str", + "type": "str", + }, + api_version="2019-10-17-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scoped_resources_begin_delete(self, resource_group): + response = await ( + await self.client.private_link_scoped_resources.begin_delete( + resource_group_name=resource_group.name, + scope_name="str", + name="str", + api_version="2019-10-17-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scoped_resources_list_by_private_link_scope(self, resource_group): + response = self.client.private_link_scoped_resources.list_by_private_link_scope( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scopes_operations.py new file mode 100644 index 0000000000000..dd8bf4a08a3bf --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scopes_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkScopesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_list(self, resource_group): + response = self.client.private_link_scopes.list( + api_version="2019-10-17-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_list_by_resource_group(self, resource_group): + response = self.client.private_link_scopes.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2019-10-17-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_begin_delete(self, resource_group): + response = self.client.private_link_scopes.begin_delete( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_get(self, resource_group): + response = self.client.private_link_scopes.get( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_create_or_update(self, resource_group): + response = self.client.private_link_scopes.create_or_update( + resource_group_name=resource_group.name, + scope_name="str", + azure_monitor_private_link_scope_payload={ + "location": "str", + "id": "str", + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_update_tags(self, resource_group): + response = self.client.private_link_scopes.update_tags( + resource_group_name=resource_group.name, + scope_name="str", + private_link_scope_tags={"tags": {"str": "str"}}, + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scopes_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scopes_operations_async.py new file mode 100644 index 0000000000000..8a8eeea7b041b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_private_link_scopes_operations_async.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementPrivateLinkScopesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_list(self, resource_group): + response = self.client.private_link_scopes.list( + api_version="2019-10-17-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_list_by_resource_group(self, resource_group): + response = self.client.private_link_scopes.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2019-10-17-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_begin_delete(self, resource_group): + response = await ( + await self.client.private_link_scopes.begin_delete( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_get(self, resource_group): + response = await self.client.private_link_scopes.get( + resource_group_name=resource_group.name, + scope_name="str", + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_create_or_update(self, resource_group): + response = await self.client.private_link_scopes.create_or_update( + resource_group_name=resource_group.name, + scope_name="str", + azure_monitor_private_link_scope_payload={ + "location": "str", + "id": "str", + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_update_tags(self, resource_group): + response = await self.client.private_link_scopes.update_tags( + resource_group_name=resource_group.name, + scope_name="str", + private_link_scope_tags={"tags": {"str": "str"}}, + api_version="2019-10-17-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_scheduled_query_rules_operations.py new file mode 100644 index 0000000000000..6ed67b5b08705 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_scheduled_query_rules_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementScheduledQueryRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_create_or_update(self, resource_group): + response = self.client.scheduled_query_rules.create_or_update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={ + "action": "action", + "location": "str", + "source": {"dataSourceId": "str", "authorizedResources": ["str"], "query": "str", "queryType": "str"}, + "autoMitigate": False, + "createdWithApiVersion": "str", + "description": "str", + "displayName": "str", + "enabled": "str", + "etag": "str", + "id": "str", + "isLegacyLogAnalyticsRule": bool, + "kind": "str", + "lastUpdatedTime": "2020-02-20 00:00:00", + "name": "str", + "provisioningState": "str", + "schedule": {"frequencyInMinutes": 0, "timeWindowInMinutes": 0}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_get(self, resource_group): + response = self.client.scheduled_query_rules.get( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_update(self, resource_group): + response = self.client.scheduled_query_rules.update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={"enabled": "str", "tags": {"str": "str"}}, + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_delete(self, resource_group): + response = self.client.scheduled_query_rules.delete( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_list_by_subscription(self, resource_group): + response = self.client.scheduled_query_rules.list_by_subscription( + api_version="2018-04-16", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_list_by_resource_group(self, resource_group): + response = self.client.scheduled_query_rules.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-04-16", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_scheduled_query_rules_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_scheduled_query_rules_operations_async.py new file mode 100644 index 0000000000000..99684931e2601 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_scheduled_query_rules_operations_async.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementScheduledQueryRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_create_or_update(self, resource_group): + response = await self.client.scheduled_query_rules.create_or_update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={ + "action": "action", + "location": "str", + "source": {"dataSourceId": "str", "authorizedResources": ["str"], "query": "str", "queryType": "str"}, + "autoMitigate": False, + "createdWithApiVersion": "str", + "description": "str", + "displayName": "str", + "enabled": "str", + "etag": "str", + "id": "str", + "isLegacyLogAnalyticsRule": bool, + "kind": "str", + "lastUpdatedTime": "2020-02-20 00:00:00", + "name": "str", + "provisioningState": "str", + "schedule": {"frequencyInMinutes": 0, "timeWindowInMinutes": 0}, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_get(self, resource_group): + response = await self.client.scheduled_query_rules.get( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_update(self, resource_group): + response = await self.client.scheduled_query_rules.update( + resource_group_name=resource_group.name, + rule_name="str", + parameters={"enabled": "str", "tags": {"str": "str"}}, + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_delete(self, resource_group): + response = await self.client.scheduled_query_rules.delete( + resource_group_name=resource_group.name, + rule_name="str", + api_version="2018-04-16", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_list_by_subscription(self, resource_group): + response = self.client.scheduled_query_rules.list_by_subscription( + api_version="2018-04-16", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_list_by_resource_group(self, resource_group): + response = self.client.scheduled_query_rules.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2018-04-16", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_service_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..bf56fdc059826 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_service_diagnostic_settings_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementServiceDiagnosticSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_service_diagnostic_settings_get(self, resource_group): + response = self.client.service_diagnostic_settings.get( + resource_uri="str", + api_version="2016-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_service_diagnostic_settings_create_or_update(self, resource_group): + response = self.client.service_diagnostic_settings.create_or_update( + resource_uri="str", + parameters={ + "location": "str", + "eventHubAuthorizationRuleId": "str", + "id": "str", + "logs": [{"enabled": bool, "category": "str", "retentionPolicy": {"days": 0, "enabled": bool}}], + "metrics": [ + {"enabled": bool, "timeGrain": "1 day, 0:00:00", "retentionPolicy": {"days": 0, "enabled": bool}} + ], + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + "type": "str", + "workspaceId": "str", + }, + api_version="2016-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_service_diagnostic_settings_update(self, resource_group): + response = self.client.service_diagnostic_settings.update( + resource_uri="str", + service_diagnostic_settings_resource={ + "eventHubAuthorizationRuleId": "str", + "logs": [{"enabled": bool, "category": "str", "retentionPolicy": {"days": 0, "enabled": bool}}], + "metrics": [ + {"enabled": bool, "timeGrain": "1 day, 0:00:00", "retentionPolicy": {"days": 0, "enabled": bool}} + ], + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + "workspaceId": "str", + }, + api_version="2016-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_service_diagnostic_settings_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_service_diagnostic_settings_operations_async.py new file mode 100644 index 0000000000000..14099512d6000 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_service_diagnostic_settings_operations_async.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementServiceDiagnosticSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_service_diagnostic_settings_get(self, resource_group): + response = await self.client.service_diagnostic_settings.get( + resource_uri="str", + api_version="2016-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_service_diagnostic_settings_create_or_update(self, resource_group): + response = await self.client.service_diagnostic_settings.create_or_update( + resource_uri="str", + parameters={ + "location": "str", + "eventHubAuthorizationRuleId": "str", + "id": "str", + "logs": [{"enabled": bool, "category": "str", "retentionPolicy": {"days": 0, "enabled": bool}}], + "metrics": [ + {"enabled": bool, "timeGrain": "1 day, 0:00:00", "retentionPolicy": {"days": 0, "enabled": bool}} + ], + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + "type": "str", + "workspaceId": "str", + }, + api_version="2016-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_service_diagnostic_settings_update(self, resource_group): + response = await self.client.service_diagnostic_settings.update( + resource_uri="str", + service_diagnostic_settings_resource={ + "eventHubAuthorizationRuleId": "str", + "logs": [{"enabled": bool, "category": "str", "retentionPolicy": {"days": 0, "enabled": bool}}], + "metrics": [ + {"enabled": bool, "timeGrain": "1 day, 0:00:00", "retentionPolicy": {"days": 0, "enabled": bool}} + ], + "serviceBusRuleId": "str", + "storageAccountId": "str", + "tags": {"str": "str"}, + "workspaceId": "str", + }, + api_version="2016-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_subscription_diagnostic_settings_operations.py new file mode 100644 index 0000000000000..3e5d4ecde7d08 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_subscription_diagnostic_settings_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementSubscriptionDiagnosticSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_subscription_diagnostic_settings_get(self, resource_group): + response = self.client.subscription_diagnostic_settings.get( + name="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_subscription_diagnostic_settings_create_or_update(self, resource_group): + response = self.client.subscription_diagnostic_settings.create_or_update( + name="str", + parameters={ + "eventHubAuthorizationRuleId": "str", + "eventHubName": "str", + "id": "str", + "location": "str", + "logs": [{"enabled": bool, "category": "str"}], + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "type": "str", + "workspaceId": "str", + }, + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_subscription_diagnostic_settings_delete(self, resource_group): + response = self.client.subscription_diagnostic_settings.delete( + name="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_subscription_diagnostic_settings_list(self, resource_group): + response = self.client.subscription_diagnostic_settings.list( + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_subscription_diagnostic_settings_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_subscription_diagnostic_settings_operations_async.py new file mode 100644 index 0000000000000..1fad324037c06 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_subscription_diagnostic_settings_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementSubscriptionDiagnosticSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_subscription_diagnostic_settings_get(self, resource_group): + response = await self.client.subscription_diagnostic_settings.get( + name="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_subscription_diagnostic_settings_create_or_update(self, resource_group): + response = await self.client.subscription_diagnostic_settings.create_or_update( + name="str", + parameters={ + "eventHubAuthorizationRuleId": "str", + "eventHubName": "str", + "id": "str", + "location": "str", + "logs": [{"enabled": bool, "category": "str"}], + "name": "str", + "serviceBusRuleId": "str", + "storageAccountId": "str", + "type": "str", + "workspaceId": "str", + }, + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_subscription_diagnostic_settings_delete(self, resource_group): + response = await self.client.subscription_diagnostic_settings.delete( + name="str", + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_subscription_diagnostic_settings_list(self, resource_group): + response = await self.client.subscription_diagnostic_settings.list( + api_version="2017-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_tenant_activity_logs_operations.py new file mode 100644 index 0000000000000..4d66f76cda266 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_tenant_activity_logs_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementTenantActivityLogsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tenant_activity_logs_list(self, resource_group): + response = self.client.tenant_activity_logs.list( + api_version="2015-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_tenant_activity_logs_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_tenant_activity_logs_operations_async.py new file mode 100644 index 0000000000000..e9910738a488b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_tenant_activity_logs_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementTenantActivityLogsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tenant_activity_logs_list(self, resource_group): + response = self.client.tenant_activity_logs.list( + api_version="2015-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_vm_insights_operations.py new file mode 100644 index 0000000000000..ccad80f867118 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_vm_insights_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementVMInsightsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_vm_insights_get_onboarding_status(self, resource_group): + response = self.client.vm_insights.get_onboarding_status( + resource_uri="str", + api_version="2018-11-27-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_vm_insights_operations_async.py b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_vm_insights_operations_async.py new file mode 100644 index 0000000000000..a421dcb95cfd3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/generated_tests/test_monitor_management_vm_insights_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMonitorManagementVMInsightsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_vm_insights_get_onboarding_status(self, resource_group): + response = await self.client.vm_insights.get_onboarding_status( + resource_uri="str", + api_version="2018-11-27-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/monitor/azure-mgmt-monitor/setup.py b/sdk/monitor/azure-mgmt-monitor/setup.py index ae79d68455024..8528a161d7a73 100644 --- a/sdk/monitor/azure-mgmt-monitor/setup.py +++ b/sdk/monitor/azure-mgmt-monitor/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", ) diff --git a/sdk/monitor/azure-mgmt-monitor/tests/_aio_testcase.py b/sdk/monitor/azure-mgmt-monitor/tests/_aio_testcase.py index 7866ca78ca232..d7c3b2719ca87 100644 --- a/sdk/monitor/azure-mgmt-monitor/tests/_aio_testcase.py +++ b/sdk/monitor/azure-mgmt-monitor/tests/_aio_testcase.py @@ -4,6 +4,7 @@ from azure.core.credentials import AccessToken from devtools_testutils import AzureMgmtRecordedTestCase + class AzureMgmtAsyncTestCase(AzureMgmtRecordedTestCase): def setUp(self): @@ -16,13 +17,13 @@ def event_loop(self): def create_mgmt_aio_client(self, client, **kwargs): if self.is_live: from azure.identity.aio import DefaultAzureCredential + credential = DefaultAzureCredential() else: - credential = Mock(spec_set=["get_token"], get_token=asyncio.coroutine(lambda _: AccessToken("fake-token", 0))) - return client( - credential=credential, - subscription_id=self.settings.SUBSCRIPTION_ID - ) + credential = Mock( + spec_set=["get_token"], get_token=asyncio.coroutine(lambda _: AccessToken("fake-token", 0)) + ) + return client(credential=credential, subscription_id=self.settings.SUBSCRIPTION_ID) def to_list(self, ait): async def lst(): @@ -30,4 +31,5 @@ async def lst(): async for item in ait: result.append(item) return result + return self.event_loop.run_until_complete(lst()) diff --git a/sdk/monitor/azure-mgmt-monitor/tests/conftest.py b/sdk/monitor/azure-mgmt-monitor/tests/conftest.py index e7981d635f56c..f4702001bc6cd 100644 --- a/sdk/monitor/azure-mgmt-monitor/tests/conftest.py +++ b/sdk/monitor/azure-mgmt-monitor/tests/conftest.py @@ -1,55 +1,35 @@ +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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. # -------------------------------------------------------------------------- import os -import platform import pytest -import sys - from dotenv import load_dotenv - -from devtools_testutils import test_proxy, add_general_regex_sanitizer -from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer - -# Ignore async tests for Python < 3.5 -collect_ignore_glob = [] -if sys.version_info < (3, 5) or platform.python_implementation() == "PyPy": - collect_ignore_glob.append("*_async.py") +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) load_dotenv() + +# For security, please avoid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): - subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000") + monitormanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + monitormanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + monitormanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + monitormanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=monitormanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") add_header_regex_sanitizer(key="Cookie", value="cookie;") - add_body_key_sanitizer(json_path="$..access_token", value="access_token") \ No newline at end of file + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor.py b/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor.py index 544e6c67b8390..030ca9b7504df 100644 --- a/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor.py +++ b/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor.py @@ -1,10 +1,10 @@ # coding: utf-8 -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # TEST SCENARIO COVERAGE @@ -52,48 +52,39 @@ import pytest from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy -AZURE_LOCATION = 'eastus' +AZURE_LOCATION = "eastus" + class TestMgmtMonitorClient(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.mgmt_client = self.create_mgmt_client( - azure.mgmt.monitor.MonitorManagementClient - ) + self.mgmt_client = self.create_mgmt_client(azure.mgmt.monitor.MonitorManagementClient) if self.is_live: from azure.mgmt.storage import StorageManagementClient - self.storage_client = self.create_mgmt_client( - StorageManagementClient - ) + + self.storage_client = self.create_mgmt_client(StorageManagementClient) from azure.mgmt.eventhub import EventHubManagementClient - self.eventhub_client = self.create_mgmt_client( - azure.mgmt.eventhub.EventHubManagementClient - ) + + self.eventhub_client = self.create_mgmt_client(azure.mgmt.eventhub.EventHubManagementClient) from azure.mgmt.loganalytics import LogAnalyticsManagementClient - self.loganalytics_client = self.create_mgmt_client( - LogAnalyticsManagementClient - ) + + self.loganalytics_client = self.create_mgmt_client(LogAnalyticsManagementClient) from azure.mgmt.web import WebSiteManagementClient - self.web_client = self.create_mgmt_client( - WebSiteManagementClient - ) + + self.web_client = self.create_mgmt_client(WebSiteManagementClient) from azure.mgmt.compute import ComputeManagementClient - self.vm_client = self.create_mgmt_client( - ComputeManagementClient - ) + + self.vm_client = self.create_mgmt_client(ComputeManagementClient) from azure.mgmt.network import NetworkManagementClient - self.network_client = self.create_mgmt_client( - NetworkManagementClient - ) + + self.network_client = self.create_mgmt_client(NetworkManagementClient) from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient - self.insight_client = self.create_mgmt_client( - ApplicationInsightsManagementClient - ) + + self.insight_client = self.create_mgmt_client(ApplicationInsightsManagementClient) from azure.mgmt.logic import LogicManagementClient - self.logic_client = self.create_mgmt_client( - LogicManagementClient - ) + + self.logic_client = self.create_mgmt_client(LogicManagementClient) def create_workflow(self, group_name, location, workflow_name): workflow = self.logic_client.workflows.create_or_update( @@ -101,29 +92,24 @@ def create_workflow(self, group_name, location, workflow_name): workflow_name, azure.mgmt.logic.models.Workflow( location=location, - definition={ + definition={ "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "contentVersion": "1.0.0.0", "parameters": {}, "triggers": {}, "actions": {}, - "outputs": {} - } - ) + "outputs": {}, + }, + ), ) return workflow # use track 1 version - def create_storage_account(self, - group_name, - location, - storage_name - ): + def create_storage_account(self, group_name, location, storage_name): from azure.mgmt.storage import models + params_create = models.StorageAccountCreateParameters( - sku=models.Sku(name=models.SkuName.standard_lrs), - kind=models.Kind.storage, - location=location + sku=models.Sku(name=models.SkuName.standard_lrs), kind=models.Kind.storage, location=location ) result_create = self.storage_client.storage_accounts.create( group_name, @@ -135,91 +121,53 @@ def create_storage_account(self, # use eventhub track 1 verison def create_event_hub_authorization_rule( - self, - group_name, - location, - name_space, - eventhub, - authorization_rule, - storage_account_id + self, group_name, location, name_space, eventhub, authorization_rule, storage_account_id ): # NamespaceCreate[put] BODY = { - "sku": { - "name": "Standard", - "tier": "Standard" - }, - "location": location, - "tags": { - "tag1": "value1", - "tag2": "value2" - } + "sku": {"name": "Standard", "tier": "Standard"}, + "location": location, + "tags": {"tag1": "value1", "tag2": "value2"}, } result = self.eventhub_client.namespaces.begin_create_or_update(group_name, name_space, BODY) result.result() # NameSpaceAuthorizationRuleCreate[put] - BODY = { - "rights": [ - "Listen", - "Send", - "Manage" - ] - } - result = self.eventhub_client.namespaces.create_or_update_authorization_rule(group_name, name_space, authorization_rule, BODY["rights"]) + BODY = {"rights": ["Listen", "Send", "Manage"]} + result = self.eventhub_client.namespaces.create_or_update_authorization_rule( + group_name, name_space, authorization_rule, BODY["rights"] + ) # EventHubCreate[put] BODY = { - "message_retention_in_days": "4", - "partition_count": "4", - "status": "Active", - "capture_description": { - "enabled": True, - "encoding": "Avro", - "interval_in_seconds": "120", - "size_limit_in_bytes": "10485763", - "destination": { - "name": "EventHubArchive.AzureBlockBlob", - "storage_account_resource_id": storage_account_id, - "blob_container": "container", - "archive_name_format": "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}" - } - } + "message_retention_in_days": "4", + "partition_count": "4", + "status": "Active", + "capture_description": { + "enabled": True, + "encoding": "Avro", + "interval_in_seconds": "120", + "size_limit_in_bytes": "10485763", + "destination": { + "name": "EventHubArchive.AzureBlockBlob", + "storage_account_resource_id": storage_account_id, + "blob_container": "container", + "archive_name_format": "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", + }, + }, } result = self.eventhub_client.event_hubs.create_or_update(group_name, name_space, eventhub, BODY) # EventHubAuthorizationRuleCreate[put] - BODY = { - "rights": [ - "Listen", - "Send", - "Manage" - ] - } - result = self.eventhub_client.event_hubs.create_or_update_authorization_rule(group_name, name_space, eventhub, authorization_rule, BODY["rights"]) + BODY = {"rights": ["Listen", "Send", "Manage"]} + result = self.eventhub_client.event_hubs.create_or_update_authorization_rule( + group_name, name_space, eventhub, authorization_rule, BODY["rights"] + ) # use track 1 version - def create_workspace( - self, - group_name, - location, - workspace_name - ): - BODY = { - "sku": { - "name": "PerNode" - }, - "retention_in_days": 30, - "location": location, - "tags": { - "tag1": "val1" - } - } - result = self.loganalytics_client.workspaces.begin_create_or_update( - group_name, - workspace_name, - BODY - ) + def create_workspace(self, group_name, location, workspace_name): + BODY = {"sku": {"name": "PerNode"}, "retention_in_days": 30, "location": location, "tags": {"tag1": "val1"}} + result = self.loganalytics_client.workspaces.begin_create_or_update(group_name, workspace_name, BODY) return result.result() # use track 1 version @@ -245,201 +193,145 @@ def create_site(self, group_name, location, site_name, app_service_plan_name): azure.mgmt.web.models.Site( location=self.region, # server_farm_id=server_farm.id - ) + ), ) site = site_async_operation.result() return site # use track 1 version def create_virtual_network(self, group_name, location, network_name, subnet_name): - - azure_operation_poller = self.network_client.virtual_networks.begin_create_or_update( - group_name, - network_name, - { - 'location': location, - 'address_space': { - 'address_prefixes': ['10.0.0.0/16'] - } - }, - ) - result_create = azure_operation_poller.result() - async_subnet_creation = self.network_client.subnets.begin_create_or_update( - group_name, - network_name, - subnet_name, - {'address_prefix': '10.0.0.0/24'} - ) - subnet_info = async_subnet_creation.result() - return subnet_info - + + azure_operation_poller = self.network_client.virtual_networks.begin_create_or_update( + group_name, + network_name, + {"location": location, "address_space": {"address_prefixes": ["10.0.0.0/16"]}}, + ) + result_create = azure_operation_poller.result() + async_subnet_creation = self.network_client.subnets.begin_create_or_update( + group_name, network_name, subnet_name, {"address_prefix": "10.0.0.0/24"} + ) + subnet_info = async_subnet_creation.result() + return subnet_info + # use track 1 version def create_network_interface(self, group_name, location, nic_name, subnet): async_nic_creation = self.network_client.network_interfaces.begin_create_or_update( group_name, nic_name, - { - 'location': location, - 'ip_configurations': [{ - 'name': 'MyIpConfig', - 'subnet': { - 'id': subnet.id - } - }] - } + {"location": location, "ip_configurations": [{"name": "MyIpConfig", "subnet": {"id": subnet.id}}]}, ) nic_info = async_nic_creation.result() return nic_info.id # use track 1 version - def create_vm( - self, - group_name, - location, - vm_name, - network_name, - subnet_name, - interface_name - ): + def create_vm(self, group_name, location, vm_name, network_name, subnet_name, interface_name): subnet = self.create_virtual_network(group_name, location, network_name, subnet_name) NIC_ID = self.create_network_interface(group_name, location, interface_name, subnet) # Create a vm with empty data disks.[put] BODY = { - "location": "eastus", - "hardware_profile": { - "vm_size": "Standard_D2_v2" - }, - "storage_profile": { - "image_reference": { - "sku": "2016-Datacenter", - "publisher": "MicrosoftWindowsServer", - "version": "latest", - "offer": "WindowsServer" + "location": "eastus", + "hardware_profile": {"vm_size": "Standard_D2_v2"}, + "storage_profile": { + "image_reference": { + "sku": "2016-Datacenter", + "publisher": "MicrosoftWindowsServer", + "version": "latest", + "offer": "WindowsServer", + }, + "os_disk": { + "caching": "ReadWrite", + "managed_disk": {"storage_account_type": "Standard_LRS"}, + "name": "myVMosdisk", + "create_option": "FromImage", + }, + "data_disks": [ + {"disk_size_gb": "1023", "create_option": "Empty", "lun": "0"}, + {"disk_size_gb": "1023", "create_option": "Empty", "lun": "1"}, + ], }, - "os_disk": { - "caching": "ReadWrite", - "managed_disk": { - "storage_account_type": "Standard_LRS" - }, - "name": "myVMosdisk", - "create_option": "FromImage" + "os_profile": { + "admin_username": "testuser", + "computer_name": "myVM", + "admin_password": "Aa1!zyx_", + "windows_configuration": {"enable_automatic_updates": True}, # need automatic update for reimage + }, + "network_profile": { + "network_interfaces": [ + { + # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Network/networkInterfaces/" + NIC_ID + "", + "id": NIC_ID, + "properties": {"primary": True}, + } + ] }, - "data_disks": [ - { - "disk_size_gb": "1023", - "create_option": "Empty", - "lun": "0" - }, - { - "disk_size_gb": "1023", - "create_option": "Empty", - "lun": "1" - } - ] - }, - "os_profile": { - "admin_username": "testuser", - "computer_name": "myVM", - "admin_password": "Aa1!zyx_", - "windows_configuration": { - "enable_automatic_updates": True # need automatic update for reimage - } - }, - "network_profile": { - "network_interfaces": [ - { - # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Network/networkInterfaces/" + NIC_ID + "", - "id": NIC_ID, - "properties": { - "primary": True - } - } - ] - } } result = self.vm_client.virtual_machines.create_or_update(group_name, vm_name, BODY) return result.result() # use track 1 version - def create_vmss( - self, - group_name, - location, - vmss_name, - network_name, - subnet_name, - interface_name - ): + def create_vmss(self, group_name, location, vmss_name, network_name, subnet_name, interface_name): subnet = self.create_virtual_network(group_name, location, network_name, subnet_name) NIC_ID = self.create_network_interface(group_name, location, interface_name, subnet) # Create a scale set with empty data disks on each vm.[put] BODY = { - "sku": { - "tier": "Standard", - "capacity": "2", - "name": "Standard_D1_v2" - }, - "location": location, - "overprovision": True, - "virtual_machine_profile": { - "storage_profile": { - "image_reference": { - "offer": "UbuntuServer", - "publisher": "Canonical", - "sku": "18.04-LTS", - "version": "latest" - }, - "os_disk": { - "caching": "ReadWrite", - "managed_disk": { - "storage_account_type": "Standard_LRS" + "sku": {"tier": "Standard", "capacity": "2", "name": "Standard_D1_v2"}, + "location": location, + "overprovision": True, + "virtual_machine_profile": { + "storage_profile": { + "image_reference": { + "offer": "UbuntuServer", + "publisher": "Canonical", + "sku": "18.04-LTS", + "version": "latest", + }, + "os_disk": { + "caching": "ReadWrite", + "managed_disk": {"storage_account_type": "Standard_LRS"}, + "create_option": "FromImage", + "disk_size_gb": "512", + }, }, - "create_option": "FromImage", - "disk_size_gb": "512" - } - }, - "os_profile": { - "computer_name_prefix": "testPC", - "admin_username": "testuser", - "admin_password": "Aa!1()-xyz" - }, - "network_profile": { - "network_interface_configurations": [ - { - "name": "testPC", - "primary": True, - "enable_ipforwarding": True, - "ip_configurations": [ - { - "name": "testPC", - "properties": { - "subnet": { - # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Network/virtualNetworks/" + NETWORK_NAME + "/subnets/" + SUBNET_NAME + "" - "id": subnet.id + "os_profile": { + "computer_name_prefix": "testPC", + "admin_username": "testuser", + "admin_password": "Aa!1()-xyz", + }, + "network_profile": { + "network_interface_configurations": [ + { + "name": "testPC", + "primary": True, + "enable_ipforwarding": True, + "ip_configurations": [ + { + "name": "testPC", + "properties": { + "subnet": { + # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Network/virtualNetworks/" + NETWORK_NAME + "/subnets/" + SUBNET_NAME + "" + "id": subnet.id + } + }, + } + ], } - } - } - ] - } - ] - } - }, - "upgrade_policy": { - "mode": "Manual" - }, - "upgrade_mode": "Manual" + ] + }, + }, + "upgrade_policy": {"mode": "Manual"}, + "upgrade_mode": "Manual", } result = self.vm_client.virtual_machine_scale_sets.create_or_update(group_name, vmss_name, BODY) vmss = result.result() return vmss - @unittest.skip('hard to test') + @unittest.skip("hard to test") @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_monitor_diagnostic_settings(self, resource_group): @@ -456,56 +348,83 @@ def test_monitor_diagnostic_settings(self, resource_group): if self.is_live: storage_account_id = self.create_storage_account(RESOURCE_GROUP, AZURE_LOCATION, STORAGE_ACCOUNT_NAME) - self.create_event_hub_authorization_rule(RESOURCE_GROUP, AZURE_LOCATION, NAMESPACE_NAME, EVENTHUB_NAME, AUTHORIZATIONRULE_NAME, storage_account_id) + self.create_event_hub_authorization_rule( + RESOURCE_GROUP, + AZURE_LOCATION, + NAMESPACE_NAME, + EVENTHUB_NAME, + AUTHORIZATIONRULE_NAME, + storage_account_id, + ) workspace = self.create_workspace(RESOURCE_GROUP, AZURE_LOCATION, WORKSPACE_NAME) workflow = self.create_workflow(RESOURCE_GROUP, AZURE_LOCATION, WORKFLOW_NAME) RESOURCE_URI = workflow.id workspace_id = workspace.id else: - RESOURCE_URI = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Logic/workflows/" + WORKFLOW_NAME - workspace_id = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.OperationalInsights/workspaces/" + WORKSPACE_NAME + RESOURCE_URI = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Logic/workflows/" + + WORKFLOW_NAME + ) + workspace_id = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.OperationalInsights/workspaces/" + + WORKSPACE_NAME + ) # Creates or Updates the diagnostic setting[put] BODY = { - "storage_account_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Storage/storageAccounts/" + STORAGE_ACCOUNT_NAME + "", - # "workspace_id": "", - "workspace_id": workspace_id, - # "event_hub_authorization_rule_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.eventhub/namespaces/" + NAMESPACE_NAME + "/eventhubs/" + EVENTHUB_NAME + "/authorizationrules/" + AUTHORIZATIONRULE_NAME + "", - "event_hub_authorization_rule_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.eventhub/namespaces/" + NAMESPACE_NAME + "/authorizationrules/" + AUTHORIZATIONRULE_NAME, - "event_hub_name": EVENTHUB_NAME, - "metrics": [ - # { - # "category": "WorkflowMetrics", - # "enabled": True, - # "retention_policy": { - # "enabled": False, - # "days": "0" - # } - # } - ], - "logs": [ - { - "category": "WorkflowRuntime", - "enabled": True, - "retention_policy": { - "enabled": False, - "days": "0" - } - } - ], - # "log_analytics_destination_type": "Dedicated" + "storage_account_id": "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Storage/storageAccounts/" + + STORAGE_ACCOUNT_NAME + + "", + # "workspace_id": "", + "workspace_id": workspace_id, + # "event_hub_authorization_rule_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.eventhub/namespaces/" + NAMESPACE_NAME + "/eventhubs/" + EVENTHUB_NAME + "/authorizationrules/" + AUTHORIZATIONRULE_NAME + "", + "event_hub_authorization_rule_id": "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/microsoft.eventhub/namespaces/" + + NAMESPACE_NAME + + "/authorizationrules/" + + AUTHORIZATIONRULE_NAME, + "event_hub_name": EVENTHUB_NAME, + "metrics": [ + # { + # "category": "WorkflowMetrics", + # "enabled": True, + # "retention_policy": { + # "enabled": False, + # "days": "0" + # } + # } + ], + "logs": [ + {"category": "WorkflowRuntime", "enabled": True, "retention_policy": {"enabled": False, "days": "0"}} + ], + # "log_analytics_destination_type": "Dedicated" } diagnostic_settings = self.mgmt_client.diagnostic_settings.create_or_update(RESOURCE_URI, INSIGHT_NAME, BODY) # TODO: resourceGroups has been changed to resourcegroups - RESOURCE_URI = "subscriptions/{sub}/resourcegroups/{group}/providers/microsoft.logic/workflows/{workflow}".format( - sub=SUBSCRIPTION_ID, - group=RESOURCE_GROUP, - workflow=WORKFLOW_NAME + RESOURCE_URI = ( + "subscriptions/{sub}/resourcegroups/{group}/providers/microsoft.logic/workflows/{workflow}".format( + sub=SUBSCRIPTION_ID, group=RESOURCE_GROUP, workflow=WORKFLOW_NAME + ) ) # List diagnostic settings categories - categories = self.mgmt_client.diagnostic_settings_category.list(RESOURCE_URI) + categories = self.mgmt_client.diagnostic_settings_category.list(RESOURCE_URI) # List diagnostic settings[get] result = self.mgmt_client.diagnostic_settings.list(RESOURCE_URI) @@ -514,43 +433,41 @@ def test_monitor_diagnostic_settings(self, resource_group): result = self.mgmt_client.diagnostic_settings.get(RESOURCE_URI, INSIGHT_NAME) # Get diagnostic settings category - self.mgmt_client.diagnostic_settings_category.get(RESOURCE_URI, categories.value[0].name) + self.mgmt_client.diagnostic_settings_category.get(RESOURCE_URI, categories.value[0].name) # Deletes the diagnostic setting[delete] result = self.mgmt_client.diagnostic_settings.delete(RESOURCE_URI, INSIGHT_NAME) - @unittest.skip('hard to test') + @unittest.skip("hard to test") @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_log_profiles(self, resource_group): SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") RESOURCE_GROUP = resource_group.name - LOGPROFILE_NAME = self.get_resource_name("logprofilex") + LOGPROFILE_NAME = self.get_resource_name("logprofilex") STORAGE_ACCOUNT_NAME = self.get_resource_name("storageaccountb") if self.is_live: storage_account_id = self.create_storage_account(RESOURCE_GROUP, AZURE_LOCATION, STORAGE_ACCOUNT_NAME) else: - storage_account_id = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Storage/storageAccounts/" + STORAGE_ACCOUNT_NAME + storage_account_id = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Storage/storageAccounts/" + + STORAGE_ACCOUNT_NAME + ) # Create or update a log profile[put] BODY = { - "location": "", - "locations": [ - "global" - ], - "categories": [ - "Write", - "Delete", - "Action" - ], - "retention_policy": { - "enabled": True, - "days": "3" - }, - # "storage_account_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Storage/storageAccounts/" + STORAGE_ACCOUNT_NAME + "", - "storage_account_id": storage_account_id, - # "service_bus_rule_id": "" + "location": "", + "locations": ["global"], + "categories": ["Write", "Delete", "Action"], + "retention_policy": {"enabled": True, "days": "3"}, + # "storage_account_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Storage/storageAccounts/" + STORAGE_ACCOUNT_NAME + "", + "storage_account_id": storage_account_id, + # "service_bus_rule_id": "" } result = self.mgmt_client.log_profiles.create_or_update(LOGPROFILE_NAME, BODY) @@ -591,9 +508,9 @@ def test_alert_rule(self, resource_group): SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") RESOURCE_GROUP = resource_group.name - APP_SERVICE_PLAN_NAME = self.get_resource_name('pyarmappserviceplan') - SITE_NAME = self.get_resource_name('pyarmsite') - ALERTRULE_NAME = rule_name = self.get_resource_name('alertrule') + APP_SERVICE_PLAN_NAME = self.get_resource_name("pyarmappserviceplan") + SITE_NAME = self.get_resource_name("pyarmsite") + ALERTRULE_NAME = rule_name = self.get_resource_name("alertrule") # site = self.create_site(RESOURCE_GROUP, AZURE_LOCATION, SITE_NAME, APP_SERVICE_PLAN_NAME) VM_NAME = "vm_name" NETWORK_NAME = "networkxx" @@ -604,27 +521,30 @@ def test_alert_rule(self, resource_group): vm = self.create_vm(RESOURCE_GROUP, AZURE_LOCATION, VM_NAME, NETWORK_NAME, SUBNET_NAME, INTERFACE_NAME) resource_id = vm.id else: - resource_id = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Compute/virtualMachines/" + VM_NAME + resource_id = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Compute/virtualMachines/" + + VM_NAME + ) data_source = azure.mgmt.monitor.models.RuleMetricDataSource( - resource_uri=resource_id, - metric_name='CPU Credits Consumed' + resource_uri=resource_id, metric_name="CPU Credits Consumed" ) # I need a subclasses of "RuleCondition" rule_condition = azure.mgmt.monitor.models.ThresholdRuleCondition( data_source=data_source, - operator='GreaterThanOrEqual', + operator="GreaterThanOrEqual", threshold=90, - window_size='PT5M', - time_aggregation='Average' + window_size="PT5M", + time_aggregation="Average", ) rule_action = azure.mgmt.monitor.models.RuleEmailAction( - send_to_service_owners=True, - custom_emails=[ - 'monitoringemail@microsoft.com' - ] + send_to_service_owners=True, custom_emails=["monitoringemail@microsoft.com"] ) # TODO: You cannot create or modify classic metric alerts for this subscription as this subscription 92f95d8f-3c67-4124-91c7-8cf07cdbf241 is being migrated or has been migrated to use new metric alerts. Learn more - aka.ms/alertclassicretirement @@ -632,15 +552,15 @@ def test_alert_rule(self, resource_group): resource_group.name, rule_name, { - 'location': AZURE_LOCATION, - 'name_properties_name': rule_name, - 'description': 'Testing Alert rule creation', - 'is_enabled': True, - 'condition': rule_condition, - 'actions': [ + "location": AZURE_LOCATION, + "name_properties_name": rule_name, + "description": "Testing Alert rule creation", + "is_enabled": True, + "condition": rule_condition, + "actions": [ # rule_action - ] - } + ], + }, ) # Get an alert rule[get] @@ -685,7 +605,7 @@ def test_alert_rule(self, resource_group): # Delete an alert rulte[delete] result = self.mgmt_client.alert_rules.delete(resource_group.name, ALERTRULE_NAME) - @unittest.skip('hard to test') + @unittest.skip("hard to test") @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_metric_alerts(self, resource_group): @@ -702,55 +622,59 @@ def test_metric_alerts(self, resource_group): vm = self.create_vm(RESOURCE_GROUP, AZURE_LOCATION, VM_NAME, NETWORK_NAME, SUBNET_NAME, INTERFACE_NAME) RESOURCE_URI = vm.id else: - RESOURCE_URI = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Compute/virtualMachines/" + VM_NAME + RESOURCE_URI = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Compute/virtualMachines/" + + VM_NAME + ) # Get a list of operations for a resource provider[get] result = self.mgmt_client.operations.list() # Create or update a metric alert[put] BODY = { - "location": "global", - "description": "This is the description of the rule1", - "severity": "3", - "enabled": True, - "scopes": [ - # "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" - RESOURCE_URI - ], - "evaluation_frequency": "PT1M", - "window_size": "PT15M", - "target_resource_type": "Microsoft.Compute/virtualMachines", - "target_resource_region": "southcentralus", - "criteria": { - "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - "all_of": [ - { - "criterion_type": "DynamicThresholdCriterion", - "name": "High_CPU_80", - "metric_name": "Percentage CPU", - "metric_namespace": "microsoft.compute/virtualmachines", - "operator": "GreaterOrLessThan", - "time_aggregation": "Average", - "dimensions": [], - "alert_sensitivity": "Medium", - "failing_periods": { - "number_of_evaluation_periods": "4", - "min_failing_periods_to_alert": "4" - }, - # "ignore_data_before": "2019-04-04T21:00:00Z" - } - ] - }, - "auto_mitigate": False, - "actions": [ - # { - # "action_group_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.insights/notificationgroups/" + NOTIFICATIONGROUP_NAME + "", - # "web_hook_properties": { - # "key11": "value11", - # "key12": "value12" - # } - # } - ] + "location": "global", + "description": "This is the description of the rule1", + "severity": "3", + "enabled": True, + "scopes": [ + # "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" + RESOURCE_URI + ], + "evaluation_frequency": "PT1M", + "window_size": "PT15M", + "target_resource_type": "Microsoft.Compute/virtualMachines", + "target_resource_region": "southcentralus", + "criteria": { + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + "all_of": [ + { + "criterion_type": "DynamicThresholdCriterion", + "name": "High_CPU_80", + "metric_name": "Percentage CPU", + "metric_namespace": "microsoft.compute/virtualmachines", + "operator": "GreaterOrLessThan", + "time_aggregation": "Average", + "dimensions": [], + "alert_sensitivity": "Medium", + "failing_periods": {"number_of_evaluation_periods": "4", "min_failing_periods_to_alert": "4"}, + # "ignore_data_before": "2019-04-04T21:00:00Z" + } + ], + }, + "auto_mitigate": False, + "actions": [ + # { + # "action_group_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.insights/notificationgroups/" + NOTIFICATIONGROUP_NAME + "", + # "web_hook_properties": { + # "key11": "value11", + # "key12": "value12" + # } + # } + ], } result = self.mgmt_client.metric_alerts.create_or_update(resource_group.name, METRIC_ALERT_NAME, BODY) @@ -769,7 +693,7 @@ def test_metric_alerts(self, resource_group): # List metric alert rules[get] result = self.mgmt_client.metric_alerts.list_by_resource_group(resource_group.name) - + # List metric alert rules[get] result = self.mgmt_client.metric_alerts.list_by_subscription() @@ -854,32 +778,22 @@ def test_metric_alerts(self, resource_group): # Delete an alert rule[delete] result = self.mgmt_client.metric_alerts.delete(resource_group.name, METRIC_ALERT_NAME) - @unittest.skip('hard to test') + @unittest.skip("hard to test") @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_action_groups(self, resource_group): ACTION_GROUP_NAME = self.get_resource_name("actiongroup") - + # Create or update an action group[put] BODY = { - "location": "Global", - "group_short_name": "sample", - "enabled": True, - "email_receivers": [ - { - "name": "John Doe's email", - "email_address": "johndoe@email.com", - "use_common_alert_schema": False - } - ], - "sms_receivers": [ - { - "name": "John Doe's mobile", - "country_code": "1", - "phone_number": "1234567890" - } - ] + "location": "Global", + "group_short_name": "sample", + "enabled": True, + "email_receivers": [ + {"name": "John Doe's email", "email_address": "johndoe@email.com", "use_common_alert_schema": False} + ], + "sms_receivers": [{"name": "John Doe's mobile", "country_code": "1", "phone_number": "1234567890"}], } result = self.mgmt_client.action_groups.create_or_update(resource_group.name, ACTION_GROUP_NAME, BODY) @@ -893,27 +807,17 @@ def test_action_groups(self, resource_group): result = self.mgmt_client.action_groups.list_by_subscription_id() # Enable the receiver[post] - BODY = { - "receiver_name": "John Doe's mobile" - } + BODY = {"receiver_name": "John Doe's mobile"} result = self.mgmt_client.action_groups.enable_receiver(resource_group.name, ACTION_GROUP_NAME, BODY) # Patch an action group[patch] - BODY = { - "tags": { - "key1": "value1", - "key2": "value2" - }, - "properties": { - "enabled": False - } - } + BODY = {"tags": {"key1": "value1", "key2": "value2"}, "properties": {"enabled": False}} result = self.mgmt_client.action_groups.update(resource_group.name, ACTION_GROUP_NAME, BODY) # Delete an action group[delete] result = self.mgmt_client.action_groups.delete(resource_group.name, ACTION_GROUP_NAME) - @pytest.mark.skipif(os.getenv('AZURE_TEST_RUN_LIVE') not in ('true', 'yes'), reason='only run live test') + @pytest.mark.skipif(os.getenv("AZURE_TEST_RUN_LIVE") not in ("true", "yes"), reason="only run live test") @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_activity_log_alerts(self, resource_group): @@ -922,36 +826,27 @@ def test_activity_log_alerts(self, resource_group): # Create or update an activity log alert[put] BODY = { - "location": "Global", - "scopes": [ - "subscriptions/" + SUBSCRIPTION_ID - ], - "enabled": True, - "condition": { - "all_of": [ - { - "field": "category", - "equals": "Administrative" - }, - { - "field": "level", - "equals": "Error" - } - ] - }, - "actions": { - "action_groups": [ - # { - # "action_group_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.insights/actionGroups/" + ACTION_GROUP_NAME + "", - # "webhook_properties": { - # "sample_webhook_property": "samplePropertyValue" - # } - # } - ] - }, - "description": "Sample activity log alert description" + "location": "Global", + "scopes": ["subscriptions/" + SUBSCRIPTION_ID], + "enabled": True, + "condition": { + "all_of": [{"field": "category", "equals": "Administrative"}, {"field": "level", "equals": "Error"}] + }, + "actions": { + "action_groups": [ + # { + # "action_group_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.insights/actionGroups/" + ACTION_GROUP_NAME + "", + # "webhook_properties": { + # "sample_webhook_property": "samplePropertyValue" + # } + # } + ] + }, + "description": "Sample activity log alert description", } - result = self.mgmt_client.activity_log_alerts.create_or_update(resource_group.name, ACTIVITY_LOG_ALERT_NAME, BODY) + result = self.mgmt_client.activity_log_alerts.create_or_update( + resource_group.name, ACTIVITY_LOG_ALERT_NAME, BODY + ) # Get an activity log alert[get] result = self.mgmt_client.activity_log_alerts.get(resource_group.name, ACTIVITY_LOG_ALERT_NAME) @@ -966,31 +861,22 @@ def test_activity_log_alerts(self, resource_group): FILTER = "resourceGroupName eq '{}'".format(resource_group.name) result = self.mgmt_client.activity_logs.list(FILTER) - # List tenant activity logs FILTER = "resourceGroupName eq '{}'".format(resource_group.name) result = self.mgmt_client.tenant_activity_logs.list(FILTER) # Patch an activity log alert[patch] - BODY = { - "tags": { - "key1": "value1", - "key2": "value2" - }, - "properties": { - "enabled": False - } - } + BODY = {"tags": {"key1": "value1", "key2": "value2"}, "properties": {"enabled": False}} result = self.mgmt_client.activity_log_alerts.update(resource_group.name, ACTIVITY_LOG_ALERT_NAME, BODY) # Delete an activity log alert[delete] result = self.mgmt_client.activity_log_alerts.delete(resource_group.name, ACTIVITY_LOG_ALERT_NAME) - @unittest.skip('hard to test') + @unittest.skip("hard to test") @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_autoscale_settings(self, resource_group): - + SUBSCRIPTION_ID = self.get_settings_value("SUBSCRIPTION_ID") RESOURCE_GROUP = resource_group.name AUTOSCALESETTING_NAME = "autoscalesetting" @@ -1000,46 +886,40 @@ def test_autoscale_settings(self, resource_group): INTERFACE_NAME = "interfacexx" if self.is_live: - vmss = self.create_vmss(RESOURCE_GROUP, AZURE_LOCATION, VMSS_NAME, NETWORK_NAME, SUBNET_NAME, INTERFACE_NAME) + vmss = self.create_vmss( + RESOURCE_GROUP, AZURE_LOCATION, VMSS_NAME, NETWORK_NAME, SUBNET_NAME, INTERFACE_NAME + ) vmss_id = vmss.id else: - vmss_id = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Compute/virtualMachineScaleSets/" + VMSS_NAME + vmss_id = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Compute/virtualMachineScaleSets/" + + VMSS_NAME + ) # Create or update an autoscale setting[put] BODY = { - "location": "West US", - "profiles": [ - { - "name": "adios", - "capacity": { - "minimum": "1", - "maximum": "10", - "default": "1" - }, - "rules": [ - ] - } - ], - "enabled": True, - "target_resource_uri": vmss_id, - "notifications": [ - { - "operation": "Scale", - "email": { - "send_to_subscription_administrator": True, - "send_to_subscription_co_administrators": True, - "custom_emails": [ - "gu@ms.com", - "ge@ns.net" - ] - }, - "webhooks": [ - ] - } - ] + "location": "West US", + "profiles": [{"name": "adios", "capacity": {"minimum": "1", "maximum": "10", "default": "1"}, "rules": []}], + "enabled": True, + "target_resource_uri": vmss_id, + "notifications": [ + { + "operation": "Scale", + "email": { + "send_to_subscription_administrator": True, + "send_to_subscription_co_administrators": True, + "custom_emails": ["gu@ms.com", "ge@ns.net"], + }, + "webhooks": [], + } + ], } result = self.mgmt_client.autoscale_settings.create_or_update(resource_group.name, AUTOSCALESETTING_NAME, BODY) - + # Get an autoscale setting[get] result = self.mgmt_client.autoscale_settings.get(resource_group.name, AUTOSCALESETTING_NAME) @@ -1051,43 +931,28 @@ def test_autoscale_settings(self, resource_group): # Update an autoscale setting[put] BODY = { - "location": "West US", - "profiles": [ - { - "name": "adios", - "capacity": { - "minimum": "1", - "maximum": "10", - "default": "1" - }, - "rules": [ - ] - } - ], - "enabled": True, - "target_resource_uri": vmss_id, - "notifications": [ - { - "operation": "Scale", - "email": { - "send_to_subscription_administrator": True, - "send_to_subscription_co_administrators": True, - "custom_emails": [ - "gu@ms.com", - "ge@ns.net" - ] - }, - "webhooks": [ - ] - } - ] + "location": "West US", + "profiles": [{"name": "adios", "capacity": {"minimum": "1", "maximum": "10", "default": "1"}, "rules": []}], + "enabled": True, + "target_resource_uri": vmss_id, + "notifications": [ + { + "operation": "Scale", + "email": { + "send_to_subscription_administrator": True, + "send_to_subscription_co_administrators": True, + "custom_emails": ["gu@ms.com", "ge@ns.net"], + }, + "webhooks": [], + } + ], } result = self.mgmt_client.autoscale_settings.update(resource_group.name, AUTOSCALESETTING_NAME, BODY) # Delete an autoscale setting[delete] result = self.mgmt_client.autoscale_settings.delete(resource_group.name, AUTOSCALESETTING_NAME) - @pytest.mark.skipif(os.getenv('AZURE_TEST_RUN_LIVE') not in ('true', 'yes'), reason='only run live test') + @pytest.mark.skipif(os.getenv("AZURE_TEST_RUN_LIVE") not in ("true", "yes"), reason="only run live test") @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_scheduled_query_rules(self, resource_group): @@ -1100,46 +965,48 @@ def test_scheduled_query_rules(self, resource_group): workspace = self.create_workspace(RESOURCE_GROUP, AZURE_LOCATION, WORKSPACE_NAME) workspace_id = workspace.id else: - workspace_id = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.OperationalInsights/workspaces/" + WORKSPACE_NAME + workspace_id = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.OperationalInsights/workspaces/" + + WORKSPACE_NAME + ) # Create or Update rule - AlertingAction[put] BODY = { - "location": "eastus", - "description": "log alert description", - "enabled": "true", - # "last_updated_time": "2017-06-23T21:23:52.0221265Z", - "provisioning_state": "Succeeded", - "source": { - "query": "Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m)", - # "data_source_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.OperationalInsights/workspaces/" + WORKSPACE_NAME + "", - "data_source_id": workspace_id, - "query_type": "ResultCount" - }, - "schedule": { - "frequency_in_minutes": "15", - "time_window_in_minutes": "15" - }, - "action": { - "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction", - "severity": "1", - "azns_action": { - "action_group": [], - "email_subject": "Email Header", - "custom_webhook_payload": "{}" + "location": "eastus", + "description": "log alert description", + "enabled": "true", + # "last_updated_time": "2017-06-23T21:23:52.0221265Z", + "provisioning_state": "Succeeded", + "source": { + "query": "Heartbeat | summarize AggregatedValue = count() by bin(TimeGenerated, 5m)", + # "data_source_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.OperationalInsights/workspaces/" + WORKSPACE_NAME + "", + "data_source_id": workspace_id, + "query_type": "ResultCount", + }, + "schedule": {"frequency_in_minutes": "15", "time_window_in_minutes": "15"}, + "action": { + "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction", + "severity": "1", + "azns_action": {"action_group": [], "email_subject": "Email Header", "custom_webhook_payload": "{}"}, + "trigger": { + "threshold_operator": "GreaterThan", + "threshold": "3", + "metric_trigger": { + "threshold_operator": "GreaterThan", + "threshold": "5", + "metric_trigger_type": "Consecutive", + "metric_column": "Computer", + }, + }, }, - "trigger": { - "threshold_operator": "GreaterThan", - "threshold": "3", - "metric_trigger": { - "threshold_operator": "GreaterThan", - "threshold": "5", - "metric_trigger_type": "Consecutive", - "metric_column": "Computer" - } - } - } } - result = self.mgmt_client.scheduled_query_rules.create_or_update(resource_group.name, SCHEDULED_QUERY_RULE_NAME, BODY) + result = self.mgmt_client.scheduled_query_rules.create_or_update( + resource_group.name, SCHEDULED_QUERY_RULE_NAME, BODY + ) # Get rule[get] result = self.mgmt_client.scheduled_query_rules.get(resource_group.name, SCHEDULED_QUERY_RULE_NAME) @@ -1151,24 +1018,24 @@ def test_scheduled_query_rules(self, resource_group): result = self.mgmt_client.scheduled_query_rules.list_by_subscription() # Patch Log Search Rule[patch] - BODY = { - "enabled": "true" - } + BODY = {"enabled": "true"} result = self.mgmt_client.scheduled_query_rules.update(resource_group.name, SCHEDULED_QUERY_RULE_NAME, BODY) # Delete rule[delete] result = self.mgmt_client.scheduled_query_rules.delete(resource_group.name, SCHEDULED_QUERY_RULE_NAME) - - @unittest.skip("(InvalidResourceType) The resource type could not be found in the namespace 'microsoft.insights' for api version '2018-06-01-preview'.") + + @unittest.skip( + "(InvalidResourceType) The resource type could not be found in the namespace 'microsoft.insights' for api version '2018-06-01-preview'." + ) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_guest_diagnostics_settings(self, resource_group): DIAGNOSTIC_SETTINGS_NAME = self.get_resource_name("diagnosticsettings") - BODY = { - "location": AZURE_LOCATION - } - self.mgmt_client.guest_diagnostics_settings.create_or_update(resource_group.name, DIAGNOSTIC_SETTINGS_NAME, BODY) + BODY = {"location": AZURE_LOCATION} + self.mgmt_client.guest_diagnostics_settings.create_or_update( + resource_group.name, DIAGNOSTIC_SETTINGS_NAME, BODY + ) self.mgmt_client.guest_diagnostics_settings.list_by_resource_group(resource_group.name) @@ -1176,14 +1043,12 @@ def test_guest_diagnostics_settings(self, resource_group): self.mgmt_client.guest_diagnostics_settings.get(resource_group.name, DIAGNOSTIC_SETTINGS_NAME) - BODY = { - "location": AZURE_LOCATION - } + BODY = {"location": AZURE_LOCATION} self.mgmt_client.guest_diagnostics_settings.update(resource_group.name, DIAGNOSTIC_SETTINGS_NAME, BODY) self.mgmt_client.guest_diagnostics_settings.delete(resource_group.name, DIAGNOSTIC_SETTINGS_NAME) -#------------------------------------------------------------------------------ -if __name__ == '__main__': +# ------------------------------------------------------------------------------ +if __name__ == "__main__": unittest.main() diff --git a/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor_async.py b/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor_async.py index c5c904bf175a9..03e4c26fabf5b 100644 --- a/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor_async.py +++ b/sdk/monitor/azure-mgmt-monitor/tests/disable_test_cli_mgmt_monitor_async.py @@ -1,10 +1,10 @@ # coding: utf-8 -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import time import pytest import unittest @@ -16,40 +16,33 @@ from _aio_testcase import AzureMgmtAsyncTestCase -AZURE_LOCATION = 'eastus' +AZURE_LOCATION = "eastus" + class TestMgmtMonitorClient(AzureMgmtAsyncTestCase): def setup_method(self, method): - self.mgmt_client = self.create_mgmt_aio_client( - azure.mgmt.monitor.aio.MonitorManagementClient - ) + self.mgmt_client = self.create_mgmt_aio_client(azure.mgmt.monitor.aio.MonitorManagementClient) if self.is_live: from azure.mgmt.storage import StorageManagementClient - self.storage_client = self.create_mgmt_client( - StorageManagementClient - ) + + self.storage_client = self.create_mgmt_client(StorageManagementClient) from azure.mgmt.eventhub import EventHubManagementClient - self.eventhub_client = self.create_mgmt_client( - azure.mgmt.eventhub.EventHubManagementClient - ) + + self.eventhub_client = self.create_mgmt_client(azure.mgmt.eventhub.EventHubManagementClient) from azure.mgmt.loganalytics import LogAnalyticsManagementClient - self.loganalytics_client = self.create_mgmt_client( - LogAnalyticsManagementClient - ) + + self.loganalytics_client = self.create_mgmt_client(LogAnalyticsManagementClient) from azure.mgmt.compute import ComputeManagementClient - self.vm_client = self.create_mgmt_client( - ComputeManagementClient - ) + + self.vm_client = self.create_mgmt_client(ComputeManagementClient) from azure.mgmt.network import NetworkManagementClient - self.network_client = self.create_mgmt_client( - NetworkManagementClient - ) + + self.network_client = self.create_mgmt_client(NetworkManagementClient) from azure.mgmt.logic import LogicManagementClient - self.logic_client = self.create_mgmt_client( - LogicManagementClient - ) + + self.logic_client = self.create_mgmt_client(LogicManagementClient) def create_workflow(self, group_name, location, workflow_name): workflow = self.logic_client.workflows.create_or_update( @@ -57,29 +50,24 @@ def create_workflow(self, group_name, location, workflow_name): workflow_name, azure.mgmt.logic.models.Workflow( location=location, - definition={ + definition={ "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "contentVersion": "1.0.0.0", "parameters": {}, "triggers": {}, "actions": {}, - "outputs": {} - } - ) + "outputs": {}, + }, + ), ) return workflow # use track 1 version - def create_storage_account(self, - group_name, - location, - storage_name - ): + def create_storage_account(self, group_name, location, storage_name): from azure.mgmt.storage import models + params_create = models.StorageAccountCreateParameters( - sku=models.Sku(name=models.SkuName.standard_lrs), - kind=models.Kind.storage, - location=location + sku=models.Sku(name=models.SkuName.standard_lrs), kind=models.Kind.storage, location=location ) result_create = self.storage_client.storage_accounts.create( group_name, @@ -91,131 +79,77 @@ def create_storage_account(self, # use eventhub track 1 verison def create_event_hub_authorization_rule( - self, - group_name, - location, - name_space, - eventhub, - authorization_rule, - storage_account_id + self, group_name, location, name_space, eventhub, authorization_rule, storage_account_id ): # NamespaceCreate[put] BODY = { - "sku": { - "name": "Standard", - "tier": "Standard" - }, - "location": location, - "tags": { - "tag1": "value1", - "tag2": "value2" - } + "sku": {"name": "Standard", "tier": "Standard"}, + "location": location, + "tags": {"tag1": "value1", "tag2": "value2"}, } result = self.eventhub_client.namespaces.begin_create_or_update(group_name, name_space, BODY) result.result() # NameSpaceAuthorizationRuleCreate[put] - BODY = { - "rights": [ - "Listen", - "Send", - "Manage" - ] - } - result = self.eventhub_client.namespaces.create_or_update_authorization_rule(group_name, name_space, authorization_rule, BODY["rights"]) + BODY = {"rights": ["Listen", "Send", "Manage"]} + result = self.eventhub_client.namespaces.create_or_update_authorization_rule( + group_name, name_space, authorization_rule, BODY["rights"] + ) # EventHubCreate[put] BODY = { - "message_retention_in_days": "4", - "partition_count": "4", - "status": "Active", - "capture_description": { - "enabled": True, - "encoding": "Avro", - "interval_in_seconds": "120", - "size_limit_in_bytes": "10485763", - "destination": { - "name": "EventHubArchive.AzureBlockBlob", - "storage_account_resource_id": storage_account_id, - "blob_container": "container", - "archive_name_format": "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}" - } - } + "message_retention_in_days": "4", + "partition_count": "4", + "status": "Active", + "capture_description": { + "enabled": True, + "encoding": "Avro", + "interval_in_seconds": "120", + "size_limit_in_bytes": "10485763", + "destination": { + "name": "EventHubArchive.AzureBlockBlob", + "storage_account_resource_id": storage_account_id, + "blob_container": "container", + "archive_name_format": "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", + }, + }, } result = self.eventhub_client.event_hubs.create_or_update(group_name, name_space, eventhub, BODY) # EventHubAuthorizationRuleCreate[put] - BODY = { - "rights": [ - "Listen", - "Send", - "Manage" - ] - } - result = self.eventhub_client.event_hubs.create_or_update_authorization_rule(group_name, name_space, eventhub, authorization_rule, BODY["rights"]) + BODY = {"rights": ["Listen", "Send", "Manage"]} + result = self.eventhub_client.event_hubs.create_or_update_authorization_rule( + group_name, name_space, eventhub, authorization_rule, BODY["rights"] + ) # use track 1 version - def create_workspace( - self, - group_name, - location, - workspace_name - ): - BODY = { - "sku": { - "name": "PerNode" - }, - "retention_in_days": 30, - "location": location, - "tags": { - "tag1": "val1" - } - } - result = self.loganalytics_client.workspaces.create_or_update( - group_name, - workspace_name, - BODY - ) + def create_workspace(self, group_name, location, workspace_name): + BODY = {"sku": {"name": "PerNode"}, "retention_in_days": 30, "location": location, "tags": {"tag1": "val1"}} + result = self.loganalytics_client.workspaces.create_or_update(group_name, workspace_name, BODY) return result.result() # use track 1 version def create_virtual_network(self, group_name, location, network_name, subnet_name): - - azure_operation_poller = self.network_client.virtual_networks.begin_create_or_update( - group_name, - network_name, - { - 'location': location, - 'address_space': { - 'address_prefixes': ['10.0.0.0/16'] - } - }, - ) - result_create = azure_operation_poller.result() - async_subnet_creation = self.network_client.subnets.begincreate_or_update( - group_name, - network_name, - subnet_name, - {'address_prefix': '10.0.0.0/24'} - ) - subnet_info = async_subnet_creation.result() - return subnet_info - + + azure_operation_poller = self.network_client.virtual_networks.begin_create_or_update( + group_name, + network_name, + {"location": location, "address_space": {"address_prefixes": ["10.0.0.0/16"]}}, + ) + result_create = azure_operation_poller.result() + async_subnet_creation = self.network_client.subnets.begincreate_or_update( + group_name, network_name, subnet_name, {"address_prefix": "10.0.0.0/24"} + ) + subnet_info = async_subnet_creation.result() + return subnet_info + # use track 1 version def create_network_interface(self, group_name, location, nic_name, subnet): async_nic_creation = self.network_client.network_interfaces.create_or_update( group_name, nic_name, - { - 'location': location, - 'ip_configurations': [{ - 'name': 'MyIpConfig', - 'subnet': { - 'id': subnet.id - } - }] - } + {"location": location, "ip_configurations": [{"name": "MyIpConfig", "subnet": {"id": subnet.id}}]}, ) nic_info = async_nic_creation.result() @@ -226,57 +160,41 @@ def create_network_interface(self, group_name, location, nic_name, subnet): # Create a vm with empty data disks.[put] BODY = { - "location": "eastus", - "hardware_profile": { - "vm_size": "Standard_D2_v2" - }, - "storage_profile": { - "image_reference": { - "sku": "2016-Datacenter", - "publisher": "MicrosoftWindowsServer", - "version": "latest", - "offer": "WindowsServer" + "location": "eastus", + "hardware_profile": {"vm_size": "Standard_D2_v2"}, + "storage_profile": { + "image_reference": { + "sku": "2016-Datacenter", + "publisher": "MicrosoftWindowsServer", + "version": "latest", + "offer": "WindowsServer", + }, + "os_disk": { + "caching": "ReadWrite", + "managed_disk": {"storage_account_type": "Standard_LRS"}, + "name": "myVMosdisk", + "create_option": "FromImage", + }, + "data_disks": [ + {"disk_size_gb": "1023", "create_option": "Empty", "lun": "0"}, + {"disk_size_gb": "1023", "create_option": "Empty", "lun": "1"}, + ], + }, + "os_profile": { + "admin_username": "testuser", + "computer_name": "myVM", + "admin_password": "Aa1!zyx_", + "windows_configuration": {"enable_automatic_updates": True}, # need automatic update for reimage }, - "os_disk": { - "caching": "ReadWrite", - "managed_disk": { - "storage_account_type": "Standard_LRS" - }, - "name": "myVMosdisk", - "create_option": "FromImage" + "network_profile": { + "network_interfaces": [ + { + # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Network/networkInterfaces/" + NIC_ID + "", + "id": NIC_ID, + "properties": {"primary": True}, + } + ] }, - "data_disks": [ - { - "disk_size_gb": "1023", - "create_option": "Empty", - "lun": "0" - }, - { - "disk_size_gb": "1023", - "create_option": "Empty", - "lun": "1" - } - ] - }, - "os_profile": { - "admin_username": "testuser", - "computer_name": "myVM", - "admin_password": "Aa1!zyx_", - "windows_configuration": { - "enable_automatic_updates": True # need automatic update for reimage - } - }, - "network_profile": { - "network_interfaces": [ - { - # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Network/networkInterfaces/" + NIC_ID + "", - "id": NIC_ID, - "properties": { - "primary": True - } - } - ] - } } result = self.vm_client.virtual_machines.create_or_update(group_name, vm_name, BODY) return result.result() @@ -298,53 +216,78 @@ def test_monitor_diagnostic_settings(self, resource_group): if self.is_live: storage_account_id = self.create_storage_account(RESOURCE_GROUP, AZURE_LOCATION, STORAGE_ACCOUNT_NAME) - self.create_event_hub_authorization_rule(RESOURCE_GROUP, AZURE_LOCATION, NAMESPACE_NAME, EVENTHUB_NAME, AUTHORIZATIONRULE_NAME, storage_account_id) + self.create_event_hub_authorization_rule( + RESOURCE_GROUP, + AZURE_LOCATION, + NAMESPACE_NAME, + EVENTHUB_NAME, + AUTHORIZATIONRULE_NAME, + storage_account_id, + ) workspace = self.create_workspace(RESOURCE_GROUP, AZURE_LOCATION, WORKSPACE_NAME) workflow = self.create_workflow(RESOURCE_GROUP, AZURE_LOCATION, WORKFLOW_NAME) RESOURCE_URI = workflow.id workspace_id = workspace.id else: - RESOURCE_URI = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Logic/workflows/" + WORKFLOW_NAME - workspace_id = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.OperationalInsights/workspaces/" + WORKSPACE_NAME + RESOURCE_URI = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Logic/workflows/" + + WORKFLOW_NAME + ) + workspace_id = ( + "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.OperationalInsights/workspaces/" + + WORKSPACE_NAME + ) # Creates or Updates the diagnostic setting[put] BODY = { - "storage_account_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Storage/storageAccounts/" + STORAGE_ACCOUNT_NAME + "", - "workspace_id": workspace_id, - "event_hub_authorization_rule_id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/microsoft.eventhub/namespaces/" + NAMESPACE_NAME + "/authorizationrules/" + AUTHORIZATIONRULE_NAME, - "event_hub_name": EVENTHUB_NAME, - "metrics": [], - "logs": [ - { - "category": "WorkflowRuntime", - "enabled": True, - "retention_policy": { - "enabled": False, - "days": "0" - } - } - ], + "storage_account_id": "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/Microsoft.Storage/storageAccounts/" + + STORAGE_ACCOUNT_NAME + + "", + "workspace_id": workspace_id, + "event_hub_authorization_rule_id": "/subscriptions/" + + SUBSCRIPTION_ID + + "/resourceGroups/" + + RESOURCE_GROUP + + "/providers/microsoft.eventhub/namespaces/" + + NAMESPACE_NAME + + "/authorizationrules/" + + AUTHORIZATIONRULE_NAME, + "event_hub_name": EVENTHUB_NAME, + "metrics": [], + "logs": [ + {"category": "WorkflowRuntime", "enabled": True, "retention_policy": {"enabled": False, "days": "0"}} + ], } diagnostic_settings = self.event_loop.run_until_complete( self.mgmt_client.diagnostic_settings.create_or_update(RESOURCE_URI, INSIGHT_NAME, BODY) ) # TODO: resourceGroups has been changed to resourcegroups - RESOURCE_URI = "subscriptions/{sub}/resourcegroups/{group}/providers/microsoft.logic/workflows/{workflow}".format( - sub=SUBSCRIPTION_ID, - group=RESOURCE_GROUP, - workflow=WORKFLOW_NAME + RESOURCE_URI = ( + "subscriptions/{sub}/resourcegroups/{group}/providers/microsoft.logic/workflows/{workflow}".format( + sub=SUBSCRIPTION_ID, group=RESOURCE_GROUP, workflow=WORKFLOW_NAME + ) ) # List diagnostic settings categories categories = self.event_loop.run_until_complete( - self.mgmt_client.diagnostic_settings_category.list(RESOURCE_URI) + self.mgmt_client.diagnostic_settings_category.list(RESOURCE_URI) ) # List diagnostic settings[get] - result = self.event_loop.run_until_complete( - self.mgmt_client.diagnostic_settings.list(RESOURCE_URI) - ) + result = self.event_loop.run_until_complete(self.mgmt_client.diagnostic_settings.list(RESOURCE_URI)) # Gets the diagnostic setting[get] diagnostic_settings = self.event_loop.run_until_complete( @@ -353,15 +296,13 @@ def test_monitor_diagnostic_settings(self, resource_group): # Get diagnostic settings category result = self.event_loop.run_until_complete( - self.mgmt_client.diagnostic_settings_category.get(RESOURCE_URI, categories.value[0].name) + self.mgmt_client.diagnostic_settings_category.get(RESOURCE_URI, categories.value[0].name) ) # Deletes the diagnostic setting[delete] - self.event_loop.run_until_complete( - self.mgmt_client.diagnostic_settings.delete(RESOURCE_URI, INSIGHT_NAME) - ) + self.event_loop.run_until_complete(self.mgmt_client.diagnostic_settings.delete(RESOURCE_URI, INSIGHT_NAME)) -#------------------------------------------------------------------------------ -if __name__ == '__main__': +# ------------------------------------------------------------------------------ +if __name__ == "__main__": unittest.main() diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_mgmt_monitor.py b/sdk/monitor/azure-mgmt-monitor/tests/test_mgmt_monitor.py deleted file mode 100644 index e02d963696282..0000000000000 --- a/sdk/monitor/azure-mgmt-monitor/tests/test_mgmt_monitor.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- -import unittest -import pytest - -import azure.mgmt.monitor -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy -from azure.core.exceptions import HttpResponseError - -AZURE_LOCATION = 'eastus' - -class TestMgmtMonitor(AzureMgmtRecordedTestCase): - - def setup_method(self, method): - self.mgmt_client = self.create_mgmt_client( - azure.mgmt.monitor.MonitorManagementClient - ) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_monitor_skip_url(self, resource_group): - resource_uri = "/subscriptions/1234abcd-1234-abcd-5678-1234abcd5678/resourceGroups/my-test-rg/providers/Microsoft.Sql/servers/mytestserver/databases/{Object.value}" - - with pytest.raises(HttpResponseError): - self.mgmt_client.metrics.list(resource_uri=resource_uri) - -#------------------------------------------------------------------------------ -if __name__ == '__main__': - unittest.main() diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_mgmt_monitor_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_mgmt_monitor_test.py new file mode 100644 index 0000000000000..adef62a59b8b1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_mgmt_monitor_test.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import unittest +import pytest + +import azure.mgmt.monitor +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy +from azure.core.exceptions import HttpResponseError + +AZURE_LOCATION = "eastus" + + +class TestMgmtMonitor(AzureMgmtRecordedTestCase): + + def setup_method(self, method): + self.mgmt_client = self.create_mgmt_client(azure.mgmt.monitor.MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_monitor_skip_url(self, resource_group): + resource_uri = "/subscriptions/1234abcd-1234-abcd-5678-1234abcd5678/resourceGroups/my-test-rg/providers/Microsoft.Sql/servers/mytestserver/databases/{Object.value}" + + with pytest.raises(HttpResponseError): + self.mgmt_client.metrics.list(resource_uri=resource_uri) + + +# ------------------------------------------------------------------------------ +if __name__ == "__main__": + unittest.main() diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_action_groups_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_action_groups_operations_async_test.py new file mode 100644 index 0000000000000..8981157038561 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_action_groups_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementActionGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_list_by_subscription_id(self, resource_group): + response = self.client.action_groups.list_by_subscription_id() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_action_groups_list_by_resource_group(self, resource_group): + response = self.client.action_groups.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_action_groups_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_action_groups_operations_test.py new file mode 100644 index 0000000000000..7e13dd95e3070 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_action_groups_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementActionGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_list_by_subscription_id(self, resource_group): + response = self.client.action_groups.list_by_subscription_id() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_action_groups_list_by_resource_group(self, resource_group): + response = self.client.action_groups.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_activity_log_alerts_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_activity_log_alerts_operations_async_test.py new file mode 100644 index 0000000000000..c9c4cc4f932f1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_activity_log_alerts_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementActivityLogAlertsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_list_by_subscription_id(self, resource_group): + response = self.client.activity_log_alerts.list_by_subscription_id() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activity_log_alerts_list_by_resource_group(self, resource_group): + response = self.client.activity_log_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_activity_log_alerts_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_activity_log_alerts_operations_test.py new file mode 100644 index 0000000000000..6c46c295d1dfa --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_activity_log_alerts_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementActivityLogAlertsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_list_by_subscription_id(self, resource_group): + response = self.client.activity_log_alerts.list_by_subscription_id() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activity_log_alerts_list_by_resource_group(self, resource_group): + response = self.client.activity_log_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_autoscale_settings_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_autoscale_settings_operations_async_test.py new file mode 100644 index 0000000000000..80aa1e291a697 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_autoscale_settings_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementAutoscaleSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_list_by_resource_group(self, resource_group): + response = self.client.autoscale_settings.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_autoscale_settings_list_by_subscription(self, resource_group): + response = self.client.autoscale_settings.list_by_subscription() + result = [r async for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_autoscale_settings_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_autoscale_settings_operations_test.py new file mode 100644 index 0000000000000..9566639188ff6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_autoscale_settings_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementAutoscaleSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_list_by_resource_group(self, resource_group): + response = self.client.autoscale_settings.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_autoscale_settings_list_by_subscription(self, resource_group): + response = self.client.autoscale_settings.list_by_subscription() + result = [r for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_event_categories_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_event_categories_operations_async_test.py new file mode 100644 index 0000000000000..bec482129464e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_event_categories_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementEventCategoriesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_event_categories_list(self, resource_group): + response = self.client.event_categories.list() + result = [r async for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_event_categories_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_event_categories_operations_test.py new file mode 100644 index 0000000000000..8beaf83677140 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_event_categories_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementEventCategoriesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_event_categories_list(self, resource_group): + response = self.client.event_categories.list() + result = [r for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_association_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_association_operations_async_test.py new file mode 100644 index 0000000000000..1840c66727d3d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_association_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementGuestDiagnosticsSettingsAssociationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_list(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_association_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_association_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_association_operations_test.py new file mode 100644 index 0000000000000..dcc3039761608 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_association_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementGuestDiagnosticsSettingsAssociationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_list(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_association_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings_association.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_operations_async_test.py new file mode 100644 index 0000000000000..08bd2fa82d593 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementGuestDiagnosticsSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_list(self, resource_group): + response = self.client.guest_diagnostics_settings.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_guest_diagnostics_settings_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_operations_test.py new file mode 100644 index 0000000000000..34abb0c2a2021 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_guest_diagnostics_settings_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementGuestDiagnosticsSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_list(self, resource_group): + response = self.client.guest_diagnostics_settings.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_guest_diagnostics_settings_list_by_resource_group(self, resource_group): + response = self.client.guest_diagnostics_settings.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_log_profiles_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_log_profiles_operations_async_test.py new file mode 100644 index 0000000000000..c617ca2b0be2d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_log_profiles_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementLogProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_log_profiles_list(self, resource_group): + response = self.client.log_profiles.list() + result = [r async for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_log_profiles_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_log_profiles_operations_test.py new file mode 100644 index 0000000000000..6167df3d73efa --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_log_profiles_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementLogProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_log_profiles_list(self, resource_group): + response = self.client.log_profiles.list() + result = [r for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_metric_alerts_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_metric_alerts_operations_async_test.py new file mode 100644 index 0000000000000..c63bf2cfe9036 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_metric_alerts_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementMetricAlertsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_list_by_subscription(self, resource_group): + response = self.client.metric_alerts.list_by_subscription() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_metric_alerts_list_by_resource_group(self, resource_group): + response = self.client.metric_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_metric_alerts_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_metric_alerts_operations_test.py new file mode 100644 index 0000000000000..b6ff88e23292a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_metric_alerts_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementMetricAlertsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_list_by_subscription(self, resource_group): + response = self.client.metric_alerts.list_by_subscription() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_metric_alerts_list_by_resource_group(self, resource_group): + response = self.client.metric_alerts.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_operations_async_test.py new file mode 100644 index 0000000000000..2d1d39b166f7b --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = await self.client.operations.list() + + assert response.value diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_operations_test.py new file mode 100644 index 0000000000000..14a62b5f2a86d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list() + + assert response.value diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_private_link_scopes_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_private_link_scopes_operations_async_test.py new file mode 100644 index 0000000000000..0c2c983f25617 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_private_link_scopes_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementPrivateLinkScopesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_list(self, resource_group): + response = self.client.private_link_scopes.list() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_scopes_list_by_resource_group(self, resource_group): + response = self.client.private_link_scopes.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_private_link_scopes_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_private_link_scopes_operations_test.py new file mode 100644 index 0000000000000..a52731d8481b7 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_private_link_scopes_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementPrivateLinkScopesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_list(self, resource_group): + response = self.client.private_link_scopes.list() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_scopes_list_by_resource_group(self, resource_group): + response = self.client.private_link_scopes.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert response diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_scheduled_query_rules_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_scheduled_query_rules_operations_async_test.py new file mode 100644 index 0000000000000..fbb3c911697bc --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_scheduled_query_rules_operations_async_test.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementScheduledQueryRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_list_by_subscription(self, resource_group): + response = self.client.scheduled_query_rules.list_by_subscription() + result = [r async for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scheduled_query_rules_list_by_resource_group(self, resource_group): + response = self.client.scheduled_query_rules.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_scheduled_query_rules_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_scheduled_query_rules_operations_test.py new file mode 100644 index 0000000000000..dfd97770c128d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_scheduled_query_rules_operations_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementScheduledQueryRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_list_by_subscription(self, resource_group): + response = self.client.scheduled_query_rules.list_by_subscription() + result = [r for r in response] + assert response + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scheduled_query_rules_list_by_resource_group(self, resource_group): + response = self.client.scheduled_query_rules.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_subscription_diagnostic_settings_operations_async_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_subscription_diagnostic_settings_operations_async_test.py new file mode 100644 index 0000000000000..6821598526d6d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_subscription_diagnostic_settings_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor.aio import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementSubscriptionDiagnosticSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_subscription_diagnostic_settings_list(self, resource_group): + response = await self.client.subscription_diagnostic_settings.list() + + assert response.value == [] diff --git a/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_subscription_diagnostic_settings_operations_test.py b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_subscription_diagnostic_settings_operations_test.py new file mode 100644 index 0000000000000..d2c443d9e04d8 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/tests/test_monitor_management_subscription_diagnostic_settings_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.monitor import MonitorManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestMonitorManagementSubscriptionDiagnosticSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MonitorManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_subscription_diagnostic_settings_list(self, resource_group): + response = self.client.subscription_diagnostic_settings.list() + + assert response.value == []